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

Side by Side Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 2967007: Disable outdated plugins, block non-sandboxed plugins. (Closed)
Patch Set: '' Created 10 years, 4 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
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/chrome_browser.gypi » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/tab_contents/tab_contents.h" 5 #include "chrome/browser/tab_contents/tab_contents.h"
6 6
7 #if defined(OS_CHROMEOS) 7 #if defined(OS_CHROMEOS)
8 // For GdkScreen 8 // For GdkScreen
9 #include <gdk/gdk.h> 9 #include <gdk/gdk.h>
10 #endif // defined(OS_CHROMEOS) 10 #endif // defined(OS_CHROMEOS)
11 11
12 #include "app/l10n_util.h" 12 #include "app/l10n_util.h"
13 #include "app/resource_bundle.h" 13 #include "app/resource_bundle.h"
14 #include "app/text_elider.h" 14 #include "app/text_elider.h"
15 #include "base/auto_reset.h" 15 #include "base/auto_reset.h"
16 #include "base/file_version_info.h" 16 #include "base/file_version_info.h"
17 #include "base/i18n/rtl.h" 17 #include "base/i18n/rtl.h"
18 #include "base/process_util.h" 18 #include "base/process_util.h"
19 #include "base/string16.h" 19 #include "base/string16.h"
20 #include "base/string_util.h" 20 #include "base/string_util.h"
21 #include "base/time.h" 21 #include "base/time.h"
22 #include "chrome/browser/autocomplete_history_manager.h" 22 #include "chrome/browser/autocomplete_history_manager.h"
23 #include "chrome/browser/autofill/autofill_manager.h" 23 #include "chrome/browser/autofill/autofill_manager.h"
24 #include "chrome/browser/blocked_plugin_manager.h"
24 #include "chrome/browser/blocked_popup_container.h" 25 #include "chrome/browser/blocked_popup_container.h"
25 #include "chrome/browser/bookmarks/bookmark_model.h" 26 #include "chrome/browser/bookmarks/bookmark_model.h"
26 #include "chrome/browser/browser.h" 27 #include "chrome/browser/browser.h"
27 #include "chrome/browser/browser_process.h" 28 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/browser_shutdown.h" 29 #include "chrome/browser/browser_shutdown.h"
29 #include "chrome/browser/cert_store.h" 30 #include "chrome/browser/cert_store.h"
30 #include "chrome/browser/character_encoding.h" 31 #include "chrome/browser/character_encoding.h"
31 #include "chrome/browser/debugger/devtools_manager.h" 32 #include "chrome/browser/debugger/devtools_manager.h"
32 #include "chrome/browser/dom_operation_notification_details.h" 33 #include "chrome/browser/dom_operation_notification_details.h"
33 #include "chrome/browser/dom_ui/dom_ui.h" 34 #include "chrome/browser/dom_ui/dom_ui.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 params->current_history_list_length = controller.entry_count(); 226 params->current_history_list_length = controller.entry_count();
226 params->url = entry.url(); 227 params->url = entry.url();
227 params->referrer = entry.referrer(); 228 params->referrer = entry.referrer();
228 params->transition = entry.transition_type(); 229 params->transition = entry.transition_type();
229 params->state = entry.content_state(); 230 params->state = entry.content_state();
230 params->navigation_type = 231 params->navigation_type =
231 GetNavigationType(controller.profile(), entry, reload_type); 232 GetNavigationType(controller.profile(), entry, reload_type);
232 params->request_time = base::Time::Now(); 233 params->request_time = base::Time::Now();
233 } 234 }
234 235
236 class DisabledPluginInfoBar : public ConfirmInfoBarDelegate {
237 public:
238 DisabledPluginInfoBar(TabContents* tab_contents,
239 const string16& name,
240 const GURL& update_url)
241 : ConfirmInfoBarDelegate(tab_contents),
242 tab_contents_(tab_contents),
243 name_(name),
244 update_url_(update_url) {
245 tab_contents->AddInfoBar(this);
246 }
247
248 virtual int GetButtons() const {
249 return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT;
250 }
251
252 virtual std::wstring GetButtonLabel(InfoBarButton button) const {
253 if (button == BUTTON_CANCEL)
254 return l10n_util::GetString(IDS_PLUGIN_ENABLE_TEMPORARILY);
255 if (button == BUTTON_OK)
256 return l10n_util::GetString(IDS_PLUGIN_UPDATE);
257 return ConfirmInfoBarDelegate::GetButtonLabel(button);
258 }
259
260 virtual std::wstring GetMessageText() const {
261 return UTF16ToWide(l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT,
262 name_));
263 }
264
265 virtual std::wstring GetLinkText() {
266 return l10n_util::GetString(IDS_LEARN_MORE);
267 }
268
269 virtual SkBitmap* GetIcon() const {
270 return ResourceBundle::GetSharedInstance().GetBitmapNamed(
271 IDR_INFOBAR_PLUGIN_INSTALL);
272 }
273
274 virtual bool Accept() {
275 tab_contents_->OpenURL(update_url_, GURL(),
276 CURRENT_TAB, PageTransition::LINK);
277 return false;
278 }
279
280 virtual bool Cancel() {
281 tab_contents_->OpenURL(GURL(chrome::kChromeUIPluginsURL), GURL(),
282 CURRENT_TAB, PageTransition::LINK);
283 return false;
284 }
285
286 virtual bool LinkClicked(WindowOpenDisposition disposition) {
287 // TODO(bauerb): Navigate to a help page explaining why we disabled
288 // the plugin, once we have one.
289 return false;
290 }
291
292 private:
293 TabContents* tab_contents_;
294 string16 name_;
295 GURL update_url_;
296 };
297
235 } // namespace 298 } // namespace
236 299
237 // ----------------------------------------------------------------------------- 300 // -----------------------------------------------------------------------------
238 301
239 // static 302 // static
240 int TabContents::find_request_id_counter_ = -1; 303 int TabContents::find_request_id_counter_ = -1;
241 304
242 305
243 TabContents::TabContents(Profile* profile, 306 TabContents::TabContents(Profile* profile,
244 SiteInstance* site_instance, 307 SiteInstance* site_instance,
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 2013
1951 void TabContents::OnDidGetApplicationInfo( 2014 void TabContents::OnDidGetApplicationInfo(
1952 int32 page_id, 2015 int32 page_id,
1953 const webkit_glue::WebApplicationInfo& info) { 2016 const webkit_glue::WebApplicationInfo& info) {
1954 web_app_info_ = info; 2017 web_app_info_ = info;
1955 2018
1956 if (delegate()) 2019 if (delegate())
1957 delegate()->OnDidGetApplicationInfo(this, page_id); 2020 delegate()->OnDidGetApplicationInfo(this, page_id);
1958 } 2021 }
1959 2022
2023 void TabContents::OnDisabledOutdatedPlugin(const string16& name,
2024 const GURL& update_url) {
2025 new DisabledPluginInfoBar(this, name, update_url);
2026 }
2027
1960 void TabContents::OnPageContents(const GURL& url, 2028 void TabContents::OnPageContents(const GURL& url,
1961 int renderer_process_id, 2029 int renderer_process_id,
1962 int32 page_id, 2030 int32 page_id,
1963 const string16& contents, 2031 const string16& contents,
1964 const std::string& language, 2032 const std::string& language,
1965 bool page_translatable) { 2033 bool page_translatable) {
1966 // Don't index any https pages. People generally don't want their bank 2034 // Don't index any https pages. People generally don't want their bank
1967 // accounts, etc. indexed on their computer, especially since some of these 2035 // accounts, etc. indexed on their computer, especially since some of these
1968 // things are not marked cachable. 2036 // things are not marked cachable.
1969 // TODO(brettw) we may want to consider more elaborate heuristics such as 2037 // TODO(brettw) we may want to consider more elaborate heuristics such as
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 RenderViewHostDelegate::Autocomplete* TabContents::GetAutocompleteDelegate() { 2234 RenderViewHostDelegate::Autocomplete* TabContents::GetAutocompleteDelegate() {
2167 if (autocomplete_history_manager_.get() == NULL) 2235 if (autocomplete_history_manager_.get() == NULL)
2168 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(this)); 2236 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(this));
2169 return autocomplete_history_manager_.get(); 2237 return autocomplete_history_manager_.get();
2170 } 2238 }
2171 2239
2172 RenderViewHostDelegate::AutoFill* TabContents::GetAutoFillDelegate() { 2240 RenderViewHostDelegate::AutoFill* TabContents::GetAutoFillDelegate() {
2173 return GetAutoFillManager(); 2241 return GetAutoFillManager();
2174 } 2242 }
2175 2243
2244 RenderViewHostDelegate::BlockedPlugin* TabContents::GetBlockedPluginDelegate() {
2245 if (blocked_plugin_manager_.get() == NULL)
2246 blocked_plugin_manager_.reset(new BlockedPluginManager(this));
2247 return blocked_plugin_manager_.get();
2248 }
2249
2176 AutomationResourceRoutingDelegate* 2250 AutomationResourceRoutingDelegate*
2177 TabContents::GetAutomationResourceRoutingDelegate() { 2251 TabContents::GetAutomationResourceRoutingDelegate() {
2178 return delegate(); 2252 return delegate();
2179 } 2253 }
2180 2254
2181 RenderViewHostDelegate::BookmarkDrag* TabContents::GetBookmarkDragDelegate() { 2255 RenderViewHostDelegate::BookmarkDrag* TabContents::GetBookmarkDragDelegate() {
2182 return bookmark_drag_; 2256 return bookmark_drag_;
2183 } 2257 }
2184 2258
2185 void TabContents::SetBookmarkDragDelegate( 2259 void TabContents::SetBookmarkDragDelegate(
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); 3309 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save));
3236 } 3310 }
3237 3311
3238 Profile* TabContents::GetProfileForPasswordManager() { 3312 Profile* TabContents::GetProfileForPasswordManager() {
3239 return profile(); 3313 return profile();
3240 } 3314 }
3241 3315
3242 bool TabContents::DidLastPageLoadEncounterSSLErrors() { 3316 bool TabContents::DidLastPageLoadEncounterSSLErrors() {
3243 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); 3317 return controller().ssl_manager()->ProcessedSSLErrorFromRequest();
3244 } 3318 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698