| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/location_bar/content_setting_image_view.h" | 5 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 
| 6 | 6 | 
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" | 
| 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 
| 9 #include "chrome/browser/themes/theme_properties.h" | 9 #include "chrome/browser/themes/theme_properties.h" | 
| 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 
| 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 
| 12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" | 12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" | 
| 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 
| 14 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" | 
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" | 
| 16 #include "ui/base/resource/resource_bundle.h" |  | 
| 17 #include "ui/base/theme_provider.h" | 16 #include "ui/base/theme_provider.h" | 
| 18 #include "ui/gfx/color_utils.h" | 17 #include "ui/gfx/color_utils.h" | 
| 19 #include "ui/views/controls/image_view.h" | 18 #include "ui/views/controls/image_view.h" | 
| 20 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" | 
| 21 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" | 
| 22 | 21 | 
| 23 | 22 | 
| 24 namespace { | 23 namespace { | 
| 25 const int kBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_CONTENT_SETTING_BUBBLE); | 24 const int kBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_CONTENT_SETTING_BUBBLE); | 
| 26 const int kStayOpenTimeMS = 3200;  // Time spent with animation fully open. | 25 const int kStayOpenTimeMS = 3200;  // Time spent with animation fully open. | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 69 void ContentSettingImageView::Update(content::WebContents* web_contents) { | 68 void ContentSettingImageView::Update(content::WebContents* web_contents) { | 
| 70   // Note: We explicitly want to call this even if |web_contents| is NULL, so we | 69   // Note: We explicitly want to call this even if |web_contents| is NULL, so we | 
| 71   // get hidden properly while the user is editing the omnibox. | 70   // get hidden properly while the user is editing the omnibox. | 
| 72   content_setting_image_model_->UpdateFromWebContents(web_contents); | 71   content_setting_image_model_->UpdateFromWebContents(web_contents); | 
| 73 | 72 | 
| 74   if (!content_setting_image_model_->is_visible()) { | 73   if (!content_setting_image_model_->is_visible()) { | 
| 75     SetVisible(false); | 74     SetVisible(false); | 
| 76     return; | 75     return; | 
| 77   } | 76   } | 
| 78 | 77 | 
| 79   SetImage(*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 78   SetImage(content_setting_image_model_->icon().AsImageSkia()); | 
| 80       content_setting_image_model_->get_icon())); |  | 
| 81   image()->SetTooltipText( | 79   image()->SetTooltipText( | 
| 82       base::UTF8ToUTF16(content_setting_image_model_->get_tooltip())); | 80       base::UTF8ToUTF16(content_setting_image_model_->get_tooltip())); | 
| 83   SetVisible(true); | 81   SetVisible(true); | 
| 84 | 82 | 
| 85   // If the content blockage should be indicated to the user, start the | 83   // If the content blockage should be indicated to the user, start the | 
| 86   // animation and record that we indicated the blockage. | 84   // animation and record that we indicated the blockage. | 
| 87   TabSpecificContentSettings* content_settings = web_contents ? | 85   TabSpecificContentSettings* content_settings = web_contents ? | 
| 88       TabSpecificContentSettings::FromWebContents(web_contents) : NULL; | 86       TabSpecificContentSettings::FromWebContents(web_contents) : NULL; | 
| 89   if (!content_settings || content_settings->IsBlockageIndicated( | 87   if (!content_settings || content_settings->IsBlockageIndicated( | 
| 90       content_setting_image_model_->get_content_settings_type())) | 88       content_setting_image_model_->get_content_settings_type())) | 
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 195         parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents( | 193         parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents( | 
| 196             ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 194             ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 
| 197                 parent_->delegate()->GetContentSettingBubbleModelDelegate(), | 195                 parent_->delegate()->GetContentSettingBubbleModelDelegate(), | 
| 198                 web_contents, parent_->profile(), | 196                 web_contents, parent_->profile(), | 
| 199                 content_setting_image_model_->get_content_settings_type()), | 197                 content_setting_image_model_->get_content_settings_type()), | 
| 200             web_contents, this, views::BubbleBorder::TOP_RIGHT)); | 198             web_contents, this, views::BubbleBorder::TOP_RIGHT)); | 
| 201     bubble_widget_->AddObserver(this); | 199     bubble_widget_->AddObserver(this); | 
| 202     bubble_widget_->Show(); | 200     bubble_widget_->Show(); | 
| 203   } | 201   } | 
| 204 } | 202 } | 
| OLD | NEW | 
|---|