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/ui/webui/extensions/extension_error_ui_util.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_error_ui_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/devtools/devtools_window.h" | 17 #include "chrome/browser/devtools/devtools_window.h" |
18 #include "chrome/browser/extensions/extension_service.h" | |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
25 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
26 #include "extensions/browser/extension_error.h" | 25 #include "extensions/browser/extension_error.h" |
27 #include "extensions/browser/extension_system.h" | 26 #include "extensions/browser/extension_registry.h" |
28 #include "extensions/browser/file_highlighter.h" | 27 #include "extensions/browser/file_highlighter.h" |
29 #include "extensions/common/constants.h" | 28 #include "extensions/common/constants.h" |
30 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
31 | 30 |
32 namespace extensions { | 31 namespace extensions { |
33 namespace error_ui_util { | 32 namespace error_ui_util { |
34 | 33 |
35 namespace { | 34 namespace { |
36 | 35 |
37 // Keys for objects passed to and from extension error UI. | 36 // Keys for objects passed to and from extension error UI. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 base::FilePath::StringType path_suffix_string; | 72 base::FilePath::StringType path_suffix_string; |
74 base::string16 error_message; | 73 base::string16 error_message; |
75 | 74 |
76 if (!args->GetString(kPathSuffixKey, &path_suffix_string) || | 75 if (!args->GetString(kPathSuffixKey, &path_suffix_string) || |
77 !args->GetString(ExtensionError::kExtensionIdKey, &extension_id) || | 76 !args->GetString(ExtensionError::kExtensionIdKey, &extension_id) || |
78 !args->GetString(ExtensionError::kMessageKey, &error_message)) { | 77 !args->GetString(ExtensionError::kMessageKey, &error_message)) { |
79 NOTREACHED(); | 78 NOTREACHED(); |
80 return; | 79 return; |
81 } | 80 } |
82 | 81 |
83 ExtensionService* extension_service = | 82 const Extension* extension = |
84 ExtensionSystem::Get(profile)->extension_service(); | 83 ExtensionRegistry::Get(profile)->GetExtensionById( |
85 if (!extension_service) | 84 extension_id, ExtensionRegistry::EVERYTHING); |
85 | |
86 if (!extension) | |
86 return; | 87 return; |
Finnur
2014/04/10 12:24:02
Looks like it would fix the crash, but do we have
Devlin
2014/04/10 16:21:08
My suspicion is that, since we really only enter t
| |
87 | 88 |
88 const Extension* extension = extension_service->GetExtensionById( | |
89 extension_id, true /* include disabled */); | |
90 | |
91 // Under no circumstances should we ever need to reference a file outside of | 89 // Under no circumstances should we ever need to reference a file outside of |
92 // the extension's directory. If it tries to, abort. | 90 // the extension's directory. If it tries to, abort. |
93 base::FilePath path_suffix(path_suffix_string); | 91 base::FilePath path_suffix(path_suffix_string); |
94 if (path_suffix.ReferencesParent()) | 92 if (path_suffix.ReferencesParent()) |
95 return; | 93 return; |
96 | 94 |
97 base::FilePath path = extension->path().Append(path_suffix); | 95 base::FilePath path = extension->path().Append(path_suffix); |
98 | 96 |
99 // Setting the title and the error message is the same for all file types. | 97 // Setting the title and the error message is the same for all file types. |
100 scoped_ptr<base::DictionaryValue> results(new base::DictionaryValue); | 98 scoped_ptr<base::DictionaryValue> results(new base::DictionaryValue); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 if (!browser || !browser->is_type_tabbed()) | 185 if (!browser || !browser->is_type_tabbed()) |
188 return; | 186 return; |
189 | 187 |
190 TabStripModel* tab_strip = browser->tab_strip_model(); | 188 TabStripModel* tab_strip = browser->tab_strip_model(); |
191 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents), | 189 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents), |
192 false); // Not through direct user gesture. | 190 false); // Not through direct user gesture. |
193 } | 191 } |
194 | 192 |
195 } // namespace error_ui_util | 193 } // namespace error_ui_util |
196 } // namespace extensions | 194 } // namespace extensions |
OLD | NEW |