| OLD | NEW |
| 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 #include <cmath> | 7 #include <cmath> |
| 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" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 class OutdatedPluginInfoBar : public ConfirmInfoBarDelegate { | 245 class OutdatedPluginInfoBar : public ConfirmInfoBarDelegate { |
| 246 public: | 246 public: |
| 247 OutdatedPluginInfoBar(TabContents* tab_contents, | 247 OutdatedPluginInfoBar(TabContents* tab_contents, |
| 248 const string16& name, | 248 const string16& name, |
| 249 const GURL& update_url) | 249 const GURL& update_url) |
| 250 : ConfirmInfoBarDelegate(tab_contents), | 250 : ConfirmInfoBarDelegate(tab_contents), |
| 251 tab_contents_(tab_contents), | 251 tab_contents_(tab_contents), |
| 252 name_(name), | 252 name_(name), |
| 253 update_url_(update_url) { | 253 update_url_(update_url) { |
| 254 UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); |
| 254 tab_contents->AddInfoBar(this); | 255 tab_contents->AddInfoBar(this); |
| 255 } | 256 } |
| 256 | 257 |
| 257 virtual int GetButtons() const { | 258 virtual int GetButtons() const { |
| 258 return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT; | 259 return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT; |
| 259 } | 260 } |
| 260 | 261 |
| 261 virtual string16 GetButtonLabel(InfoBarButton button) const { | 262 virtual string16 GetButtonLabel(InfoBarButton button) const { |
| 262 if (button == BUTTON_CANCEL) | 263 if (button == BUTTON_CANCEL) |
| 263 return l10n_util::GetStringUTF16(IDS_PLUGIN_ENABLE_TEMPORARILY); | 264 return l10n_util::GetStringUTF16(IDS_PLUGIN_ENABLE_TEMPORARILY); |
| 264 if (button == BUTTON_OK) | 265 if (button == BUTTON_OK) |
| 265 return l10n_util::GetStringUTF16(IDS_PLUGIN_UPDATE); | 266 return l10n_util::GetStringUTF16(IDS_PLUGIN_UPDATE); |
| 266 return ConfirmInfoBarDelegate::GetButtonLabel(button); | 267 return ConfirmInfoBarDelegate::GetButtonLabel(button); |
| 267 } | 268 } |
| 268 | 269 |
| 269 virtual string16 GetMessageText() const { | 270 virtual string16 GetMessageText() const { |
| 270 return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_); | 271 return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_); |
| 271 } | 272 } |
| 272 | 273 |
| 273 virtual string16 GetLinkText() { | 274 virtual string16 GetLinkText() { |
| 274 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 275 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 275 } | 276 } |
| 276 | 277 |
| 277 virtual SkBitmap* GetIcon() const { | 278 virtual SkBitmap* GetIcon() const { |
| 278 return ResourceBundle::GetSharedInstance().GetBitmapNamed( | 279 return ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 279 IDR_INFOBAR_PLUGIN_INSTALL); | 280 IDR_INFOBAR_PLUGIN_INSTALL); |
| 280 } | 281 } |
| 281 | 282 |
| 282 virtual bool Accept() { | 283 virtual bool Accept() { |
| 284 UserMetrics::RecordAction( |
| 285 UserMetricsAction("OutdatedPluginInfobar.Update")); |
| 283 tab_contents_->OpenURL(update_url_, GURL(), | 286 tab_contents_->OpenURL(update_url_, GURL(), |
| 284 NEW_FOREGROUND_TAB, PageTransition::LINK); | 287 NEW_FOREGROUND_TAB, PageTransition::LINK); |
| 285 return false; | 288 return false; |
| 286 } | 289 } |
| 287 | 290 |
| 288 virtual bool Cancel() { | 291 virtual bool Cancel() { |
| 292 UserMetrics::RecordAction( |
| 293 UserMetricsAction("OutdatedPluginInfobar.AllowThisTime")); |
| 289 tab_contents_->render_view_host()->LoadBlockedPlugins(); | 294 tab_contents_->render_view_host()->LoadBlockedPlugins(); |
| 290 return true; | 295 return true; |
| 291 } | 296 } |
| 292 | 297 |
| 293 virtual bool LinkClicked(WindowOpenDisposition disposition) { | 298 virtual bool LinkClicked(WindowOpenDisposition disposition) { |
| 299 UserMetrics::RecordAction( |
| 300 UserMetricsAction("OutdatedPluginInfobar.LearnMore")); |
| 294 // TODO(bauerb): Navigate to a help page explaining why we disabled | 301 // TODO(bauerb): Navigate to a help page explaining why we disabled |
| 295 // the plugin, once we have one. | 302 // the plugin, once we have one. |
| 296 return false; | 303 return false; |
| 297 } | 304 } |
| 298 | 305 |
| 299 virtual void InfoBarClosed() { | 306 virtual void InfoBarClosed() { |
| 307 UserMetrics::RecordAction( |
| 308 UserMetricsAction("OutdatedPluginInfobar.Closed")); |
| 300 delete this; | 309 delete this; |
| 301 } | 310 } |
| 302 | 311 |
| 303 private: | 312 private: |
| 304 TabContents* tab_contents_; | 313 TabContents* tab_contents_; |
| 305 string16 name_; | 314 string16 name_; |
| 306 GURL update_url_; | 315 GURL update_url_; |
| 307 }; | 316 }; |
| 308 | 317 |
| 309 } // namespace | 318 } // namespace |
| (...skipping 3053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3363 } | 3372 } |
| 3364 | 3373 |
| 3365 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 3374 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
| 3366 render_manager_.SwapInRenderViewHost(rvh); | 3375 render_manager_.SwapInRenderViewHost(rvh); |
| 3367 } | 3376 } |
| 3368 | 3377 |
| 3369 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3378 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 3370 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 3379 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 3371 rwh_view->SetSize(view()->GetContainerSize()); | 3380 rwh_view->SetSize(view()->GetContainerSize()); |
| 3372 } | 3381 } |
| OLD | NEW |