OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 #include <stddef.h> | 6 #include <stddef.h> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // optionally with an associated keybinding. | 72 // optionally with an associated keybinding. |
73 void CreateExtension(ExtensionType type, | 73 void CreateExtension(ExtensionType type, |
74 bool has_keybinding, | 74 bool has_keybinding, |
75 extensions::Manifest::Location location) { | 75 extensions::Manifest::Location location) { |
76 DictionaryBuilder manifest; | 76 DictionaryBuilder manifest; |
77 manifest.Set("version", "1.0"); | 77 manifest.Set("version", "1.0"); |
78 manifest.Set("name", "extension"); | 78 manifest.Set("name", "extension"); |
79 manifest.Set("manifest_version", 2); | 79 manifest.Set("manifest_version", 2); |
80 switch (type) { | 80 switch (type) { |
81 case PAGE_ACTION: | 81 case PAGE_ACTION: |
82 manifest.Set("page_action", DictionaryBuilder()); | 82 manifest.Set("page_action", DictionaryBuilder().Build()); |
83 break; | 83 break; |
84 case BROWSER_ACTION: | 84 case BROWSER_ACTION: |
85 manifest.Set("browser_action", DictionaryBuilder()); | 85 manifest.Set("browser_action", DictionaryBuilder().Build()); |
86 break; | 86 break; |
87 case APP: | 87 case APP: |
88 manifest.Set("app", | 88 manifest.Set( |
89 std::move(DictionaryBuilder().Set( | 89 "app", |
90 "launch", std::move(DictionaryBuilder().Set( | 90 DictionaryBuilder() |
91 "web_url", "http://www.example.com"))))); | 91 .Set("launch", DictionaryBuilder() |
| 92 .Set("web_url", "http://www.example.com") |
| 93 .Build()) |
| 94 .Build()); |
92 break; | 95 break; |
93 } | 96 } |
94 | 97 |
95 if (has_keybinding) { | 98 if (has_keybinding) { |
96 DictionaryBuilder command; | 99 DictionaryBuilder command; |
97 command.Set(type == PAGE_ACTION ? "_execute_page_action" | 100 command.Set(type == PAGE_ACTION ? "_execute_page_action" |
98 : "_execute_browser_action", | 101 : "_execute_browser_action", |
99 std::move(DictionaryBuilder().Set( | 102 DictionaryBuilder() |
100 "suggested_key", | 103 .Set("suggested_key", DictionaryBuilder() |
101 std::move(DictionaryBuilder() | 104 .Set("mac", "MacCtrl+Shift+E") |
102 .Set("mac", "MacCtrl+Shift+E") | 105 .Set("default", "Ctrl+Shift+E") |
103 .Set("default", "Ctrl+Shift+E"))))); | 106 .Build()) |
104 manifest.Set("commands", std::move(command)); | 107 .Build()); |
| 108 manifest.Set("commands", command.Build()); |
105 } | 109 } |
106 | 110 |
107 extension_ = extensions::ExtensionBuilder() | 111 extension_ = extensions::ExtensionBuilder() |
108 .SetManifest(std::move(manifest)) | 112 .SetManifest(manifest.Build()) |
109 .SetID(crx_file::id_util::GenerateId("foo")) | 113 .SetID(crx_file::id_util::GenerateId("foo")) |
110 .SetLocation(location) | 114 .SetLocation(location) |
111 .Build(); | 115 .Build(); |
112 extensionService_->AddExtension(extension_.get()); | 116 extensionService_->AddExtension(extension_.get()); |
113 if (has_keybinding) { | 117 if (has_keybinding) { |
114 // Slight hack: manually notify the command service of the extension since | 118 // Slight hack: manually notify the command service of the extension since |
115 // it doesn't go through the normal installation flow. | 119 // it doesn't go through the normal installation flow. |
116 extensions::CommandService::Get(profile())->UpdateKeybindingsForTest( | 120 extensions::CommandService::Get(profile())->UpdateKeybindingsForTest( |
117 extension_.get()); | 121 extension_.get()); |
118 } | 122 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // Make sure there is always enough room for the icon and margin. | 370 // Make sure there is always enough room for the icon and margin. |
367 int minHeight = extension_installed_bubble::kIconSize + | 371 int minHeight = extension_installed_bubble::kIconSize + |
368 (2 * extension_installed_bubble::kOuterVerticalMargin); | 372 (2 * extension_installed_bubble::kOuterVerticalMargin); |
369 EXPECT_GT(height, minHeight); | 373 EXPECT_GT(height, minHeight); |
370 | 374 |
371 // Make sure the "show me" link is visible. | 375 // Make sure the "show me" link is visible. |
372 EXPECT_FALSE([[controller appInstalledShortcutLink] isHidden]); | 376 EXPECT_FALSE([[controller appInstalledShortcutLink] isHidden]); |
373 | 377 |
374 [controller close]; | 378 [controller close]; |
375 } | 379 } |
OLD | NEW |