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

Side by Side Diff: chrome/browser/extensions/extension_install_ui.cc

Issue 430003: Revert change that disallowed content scripts access to file:// (Closed)
Patch Set: Can't go back, only through Created 11 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_startup_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_install_ui.h" 5 #include "chrome/browser/extensions/extension_install_ui.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/browser_list.h" 14 #include "chrome/browser/browser_list.h"
15 #include "chrome/browser/browser_window.h" 15 #include "chrome/browser/browser_window.h"
16 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" 16 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h"
17 #include "chrome/browser/profile.h" 17 #include "chrome/browser/profile.h"
18 #include "chrome/browser/tab_contents/tab_contents.h" 18 #include "chrome/browser/tab_contents/tab_contents.h"
19 #if defined(TOOLKIT_VIEWS) // TODO(port) 19 #if defined(TOOLKIT_VIEWS) // TODO(port)
20 #include "chrome/browser/views/extensions/extension_installed_bubble.h" 20 #include "chrome/browser/views/extensions/extension_installed_bubble.h"
21 #endif // TOOLKIT_VIEWS 21 #endif // TOOLKIT_VIEWS
22 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
23 #include "chrome/common/notification_service.h" 23 #include "chrome/common/notification_service.h"
24 #include "chrome/common/url_constants.h"
24 #include "grit/browser_resources.h" 25 #include "grit/browser_resources.h"
25 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
26 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
27 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
28 29
29 #if defined(TOOLKIT_GTK) 30 #if defined(TOOLKIT_GTK)
30 #include "chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h" 31 #include "chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h"
31 #include "chrome/browser/gtk/gtk_theme_provider.h" 32 #include "chrome/browser/gtk/gtk_theme_provider.h"
32 #endif 33 #endif
33 34
34 namespace { 35 namespace {
35 36
36 static std::wstring GetInstallWarning(Extension* extension) { 37 static std::wstring GetInstallWarning(Extension* extension) {
37 // If the extension has a plugin, it's easy: the plugin has the most severe 38 // If the extension has a plugin, it's easy: the plugin has the most severe
38 // warning. 39 // warning.
39 if (!extension->plugins().empty()) 40 if (!extension->plugins().empty())
40 return l10n_util::GetString(IDS_EXTENSION_PROMPT_WARNING_NEW_FULL_ACCESS); 41 return l10n_util::GetString(IDS_EXTENSION_PROMPT_WARNING_NEW_FULL_ACCESS);
41 42
43 // We also show the severe warning if the extension has access to any file://
44 // URLs. They aren't *quite* as dangerous as full access to the system via
45 // NPAPI, but pretty dang close. Content scripts are currently the only way
46 // that extension can get access to file:// URLs.
47 for (UserScriptList::const_iterator script =
48 extension->content_scripts().begin();
49 script != extension->content_scripts().end();
50 ++script) {
51 for (UserScript::PatternList::const_iterator pattern =
52 script->url_patterns().begin();
Finnur 2009/11/22 00:13:44 nit: That looks like 3 spaces, not 4... ? :) Also
53 pattern != script->url_patterns().end();
54 ++pattern) {
55 if (pattern->scheme() == chrome::kFileScheme) {
56 return l10n_util::GetString(
57 IDS_EXTENSION_PROMPT_WARNING_NEW_FULL_ACCESS);
58 }
59 }
60 }
61
42 // Otherwise, we go in descending order of severity: all hosts, several hosts, 62 // Otherwise, we go in descending order of severity: all hosts, several hosts,
43 // a single host, no hosts. For each of these, we also have a variation of the 63 // a single host, no hosts. For each of these, we also have a variation of the
44 // message for when api permissions are also requested. 64 // message for when api permissions are also requested.
45 if (extension->HasAccessToAllHosts()) { 65 if (extension->HasAccessToAllHosts()) {
46 if (extension->api_permissions().empty()) 66 if (extension->api_permissions().empty())
47 return l10n_util::GetString(IDS_EXTENSION_PROMPT_WARNING_NEW_ALL_HOSTS); 67 return l10n_util::GetString(IDS_EXTENSION_PROMPT_WARNING_NEW_ALL_HOSTS);
48 else 68 else
49 return l10n_util::GetString( 69 return l10n_util::GetString(
50 IDS_EXTENSION_PROMPT_WARNING_NEW_ALL_HOSTS_AND_BROWSER); 70 IDS_EXTENSION_PROMPT_WARNING_NEW_ALL_HOSTS_AND_BROWSER);
51 } 71 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 InfoBarDelegate* ExtensionInstallUI::GetNewInfoBarDelegate( 243 InfoBarDelegate* ExtensionInstallUI::GetNewInfoBarDelegate(
224 Extension* new_theme, TabContents* tab_contents) { 244 Extension* new_theme, TabContents* tab_contents) {
225 #if defined(TOOLKIT_GTK) 245 #if defined(TOOLKIT_GTK)
226 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, 246 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme,
227 previous_theme_id_, previous_use_gtk_theme_); 247 previous_theme_id_, previous_use_gtk_theme_);
228 #else 248 #else
229 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, 249 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme,
230 previous_theme_id_); 250 previous_theme_id_);
231 #endif 251 #endif
232 } 252 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_startup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698