| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_action_test_util.h" | 5 #include "chrome/browser/extensions/extension_action_test_util.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "chrome/browser/extensions/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 9 #include "chrome/browser/extensions/extension_action_manager.h" |
| 10 #include "chrome/browser/extensions/extension_toolbar_model.h" | 10 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 size_t GetVisiblePageActionCount(content::WebContents* web_contents) { | 109 size_t GetVisiblePageActionCount(content::WebContents* web_contents) { |
| 110 return GetPageActionCount(web_contents, true); | 110 return GetPageActionCount(web_contents, true); |
| 111 } | 111 } |
| 112 | 112 |
| 113 size_t GetTotalPageActionCount(content::WebContents* web_contents) { | 113 size_t GetTotalPageActionCount(content::WebContents* web_contents) { |
| 114 return GetPageActionCount(web_contents, false); | 114 return GetPageActionCount(web_contents, false); |
| 115 } | 115 } |
| 116 | 116 |
| 117 scoped_refptr<const Extension> CreateActionExtension(const std::string& name, | 117 scoped_refptr<const Extension> CreateActionExtension(const std::string& name, |
| 118 ActionType action_type) { | 118 ActionType action_type) { |
| 119 return CreateActionExtension(name, action_type, Manifest::INTERNAL); |
| 120 } |
| 121 |
| 122 scoped_refptr<const Extension> CreateActionExtension( |
| 123 const std::string& name, |
| 124 ActionType action_type, |
| 125 Manifest::Location location) { |
| 119 DictionaryBuilder manifest; | 126 DictionaryBuilder manifest; |
| 120 manifest.Set("name", name) | 127 manifest.Set("name", name) |
| 121 .Set("description", "An extension") | 128 .Set("description", "An extension") |
| 122 .Set("manifest_version", 2) | 129 .Set("manifest_version", 2) |
| 123 .Set("version", "1.0.0"); | 130 .Set("version", "1.0.0"); |
| 124 | 131 |
| 125 const char* action_key = nullptr; | 132 const char* action_key = nullptr; |
| 126 switch (action_type) { | 133 switch (action_type) { |
| 127 case NO_ACTION: | 134 case NO_ACTION: |
| 128 break; | 135 break; |
| 129 case PAGE_ACTION: | 136 case PAGE_ACTION: |
| 130 action_key = manifest_keys::kPageAction; | 137 action_key = manifest_keys::kPageAction; |
| 131 break; | 138 break; |
| 132 case BROWSER_ACTION: | 139 case BROWSER_ACTION: |
| 133 action_key = manifest_keys::kBrowserAction; | 140 action_key = manifest_keys::kBrowserAction; |
| 134 break; | 141 break; |
| 135 } | 142 } |
| 136 | 143 |
| 137 if (action_key) | 144 if (action_key) |
| 138 manifest.Set(action_key, DictionaryBuilder().Pass()); | 145 manifest.Set(action_key, DictionaryBuilder().Pass()); |
| 139 | 146 |
| 140 return ExtensionBuilder().SetManifest(manifest.Pass()). | 147 return ExtensionBuilder().SetManifest(manifest.Pass()). |
| 141 SetID(crx_file::id_util::GenerateId(name)). | 148 SetID(crx_file::id_util::GenerateId(name)). |
| 149 SetLocation(location). |
| 142 Build(); | 150 Build(); |
| 143 } | 151 } |
| 144 | 152 |
| 145 ExtensionToolbarModel* CreateToolbarModelForProfile(Profile* profile) { | 153 ExtensionToolbarModel* CreateToolbarModelForProfile(Profile* profile) { |
| 146 return CreateToolbarModelImpl(profile, true); | 154 return CreateToolbarModelImpl(profile, true); |
| 147 } | 155 } |
| 148 | 156 |
| 149 ExtensionToolbarModel* CreateToolbarModelForProfileWithoutWaitingForReady( | 157 ExtensionToolbarModel* CreateToolbarModelForProfileWithoutWaitingForReady( |
| 150 Profile* profile) { | 158 Profile* profile) { |
| 151 return CreateToolbarModelImpl(profile, false); | 159 return CreateToolbarModelImpl(profile, false); |
| 152 } | 160 } |
| 153 | 161 |
| 154 } // namespace extension_action_test_util | 162 } // namespace extension_action_test_util |
| 155 } // namespace extensions | 163 } // namespace extensions |
| OLD | NEW |