Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(820)

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_error_ui_util.cc

Issue 226743005: Check Extension in extension_error_ui_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add NOTREACHED() Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
87 NOTREACHED();
86 return; 88 return;
87 89 }
88 const Extension* extension = extension_service->GetExtensionById(
89 extension_id, true /* include disabled */);
90 90
91 // Under no circumstances should we ever need to reference a file outside of 91 // Under no circumstances should we ever need to reference a file outside of
92 // the extension's directory. If it tries to, abort. 92 // the extension's directory. If it tries to, abort.
93 base::FilePath path_suffix(path_suffix_string); 93 base::FilePath path_suffix(path_suffix_string);
94 if (path_suffix.ReferencesParent()) 94 if (path_suffix.ReferencesParent())
95 return; 95 return;
96 96
97 base::FilePath path = extension->path().Append(path_suffix); 97 base::FilePath path = extension->path().Append(path_suffix);
98 98
99 // Setting the title and the error message is the same for all file types. 99 // Setting the title and the error message is the same for all file types.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (!browser || !browser->is_type_tabbed()) 187 if (!browser || !browser->is_type_tabbed())
188 return; 188 return;
189 189
190 TabStripModel* tab_strip = browser->tab_strip_model(); 190 TabStripModel* tab_strip = browser->tab_strip_model();
191 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents), 191 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents),
192 false); // Not through direct user gesture. 192 false); // Not through direct user gesture.
193 } 193 }
194 194
195 } // namespace error_ui_util 195 } // namespace error_ui_util
196 } // namespace extensions 196 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698