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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_service_test_base.h" | 9 #include "chrome/browser/extensions/extension_service_test_base.h" |
10 #include "chrome/browser/extensions/extension_toolbar_model.h" | 10 #include "chrome/browser/extensions/extension_toolbar_model.h" |
11 #include "chrome/browser/extensions/test_extension_system.h" | 11 #include "chrome/browser/extensions/test_extension_system.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/extensions/api/extension_action/action_info.h" | 13 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 14 #include "components/crx_file/id_util.h" |
14 #include "extensions/browser/extension_prefs.h" | 15 #include "extensions/browser/extension_prefs.h" |
15 #include "extensions/browser/extension_registry.h" | 16 #include "extensions/browser/extension_registry.h" |
16 #include "extensions/browser/extension_system.h" | 17 #include "extensions/browser/extension_system.h" |
17 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
18 #include "extensions/common/extension_builder.h" | 19 #include "extensions/common/extension_builder.h" |
19 #include "extensions/common/feature_switch.h" | 20 #include "extensions/common/feature_switch.h" |
20 #include "extensions/common/id_util.h" | |
21 #include "extensions/common/manifest_constants.h" | 21 #include "extensions/common/manifest_constants.h" |
22 #include "extensions/common/value_builder.h" | 22 #include "extensions/common/value_builder.h" |
23 | 23 |
24 namespace extensions { | 24 namespace extensions { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Create an extension. If |action_key| is non-NULL, it should point to either | 28 // Create an extension. If |action_key| is non-NULL, it should point to either |
29 // kBrowserAction or kPageAction, and the extension will have the associated | 29 // kBrowserAction or kPageAction, and the extension will have the associated |
30 // action. | 30 // action. |
31 scoped_refptr<const Extension> GetActionExtension(const std::string& name, | 31 scoped_refptr<const Extension> GetActionExtension(const std::string& name, |
32 const char* action_key) { | 32 const char* action_key) { |
33 DictionaryBuilder manifest; | 33 DictionaryBuilder manifest; |
34 manifest.Set("name", name) | 34 manifest.Set("name", name) |
35 .Set("description", "An extension") | 35 .Set("description", "An extension") |
36 .Set("manifest_version", 2) | 36 .Set("manifest_version", 2) |
37 .Set("version", "1.0.0"); | 37 .Set("version", "1.0.0"); |
38 if (action_key) | 38 if (action_key) |
39 manifest.Set(action_key, DictionaryBuilder().Pass()); | 39 manifest.Set(action_key, DictionaryBuilder().Pass()); |
40 | 40 |
41 return ExtensionBuilder().SetManifest(manifest.Pass()) | 41 return ExtensionBuilder().SetManifest(manifest.Pass()) |
42 .SetID(id_util::GenerateId(name)) | 42 .SetID(crx_file::id_util::GenerateId(name)) |
43 .Build(); | 43 .Build(); |
44 } | 44 } |
45 | 45 |
46 // A simple observer that tracks the number of times certain events occur. | 46 // A simple observer that tracks the number of times certain events occur. |
47 class ExtensionToolbarModelTestObserver | 47 class ExtensionToolbarModelTestObserver |
48 : public ExtensionToolbarModel::Observer { | 48 : public ExtensionToolbarModel::Observer { |
49 public: | 49 public: |
50 explicit ExtensionToolbarModelTestObserver(ExtensionToolbarModel* model); | 50 explicit ExtensionToolbarModelTestObserver(ExtensionToolbarModel* model); |
51 virtual ~ExtensionToolbarModelTestObserver(); | 51 virtual ~ExtensionToolbarModelTestObserver(); |
52 | 52 |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 | 683 |
684 // With the switch on, extensions with page actions and no action should also | 684 // With the switch on, extensions with page actions and no action should also |
685 // be displayed in the toolbar. | 685 // be displayed in the toolbar. |
686 EXPECT_EQ(3u, num_toolbar_items()); | 686 EXPECT_EQ(3u, num_toolbar_items()); |
687 EXPECT_EQ(browser_action(), GetExtensionAtIndex(0u)); | 687 EXPECT_EQ(browser_action(), GetExtensionAtIndex(0u)); |
688 EXPECT_EQ(page_action(), GetExtensionAtIndex(1u)); | 688 EXPECT_EQ(page_action(), GetExtensionAtIndex(1u)); |
689 EXPECT_EQ(no_action(), GetExtensionAtIndex(2u)); | 689 EXPECT_EQ(no_action(), GetExtensionAtIndex(2u)); |
690 } | 690 } |
691 | 691 |
692 } // namespace extensions | 692 } // namespace extensions |
OLD | NEW |