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

Side by Side Diff: chrome/browser/ui/views/location_bar/content_setting_image_view.cc

Issue 11418043: Remove TabContents from OmniboxEditController and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros Created 8 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 | Annotate | Revision Log
OLDNEW
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/utf_string_conversions.h" 7 #include "base/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/ui/content_settings/content_setting_bubble_model.h" 9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents.h"
12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" 11 #include "chrome/browser/ui/views/content_setting_bubble_contents.h"
13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
14 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
15 #include "third_party/skia/include/core/SkShader.h" 14 #include "third_party/skia/include/core/SkShader.h"
16 #include "ui/base/animation/slide_animation.h" 15 #include "ui/base/animation/slide_animation.h"
17 #include "ui/base/animation/tween.h" 16 #include "ui/base/animation/tween.h"
18 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/skia_util.h" 20 #include "ui/gfx/skia_util.h"
(...skipping 28 matching lines...) Expand all
50 bubble_widget_(NULL) { 49 bubble_widget_(NULL) {
51 } 50 }
52 51
53 ContentSettingImageView::~ContentSettingImageView() { 52 ContentSettingImageView::~ContentSettingImageView() {
54 if (bubble_widget_) { 53 if (bubble_widget_) {
55 bubble_widget_->RemoveObserver(this); 54 bubble_widget_->RemoveObserver(this);
56 bubble_widget_ = NULL; 55 bubble_widget_ = NULL;
57 } 56 }
58 } 57 }
59 58
60 void ContentSettingImageView::Update(TabContents* tab_contents) { 59 void ContentSettingImageView::Update(WebContents* web_contents) {
61 if (tab_contents) { 60 if (web_contents) {
62 content_setting_image_model_->UpdateFromWebContents( 61 content_setting_image_model_->UpdateFromWebContents(web_contents);
63 tab_contents->web_contents());
64 } 62 }
65 if (!content_setting_image_model_->is_visible()) { 63 if (!content_setting_image_model_->is_visible()) {
66 SetVisible(false); 64 SetVisible(false);
67 return; 65 return;
68 } 66 }
69 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 67 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
70 content_setting_image_model_->get_icon())); 68 content_setting_image_model_->get_icon()));
71 SetTooltipText(UTF8ToUTF16(content_setting_image_model_->get_tooltip())); 69 SetTooltipText(UTF8ToUTF16(content_setting_image_model_->get_tooltip()));
72 SetVisible(true); 70 SetVisible(true);
73 71
74 TabSpecificContentSettings* content_settings = NULL; 72 TabSpecificContentSettings* content_settings = NULL;
75 if (tab_contents) { 73 if (web_contents) {
76 content_settings = TabSpecificContentSettings::FromWebContents( 74 content_settings =
77 tab_contents->web_contents()); 75 TabSpecificContentSettings::FromWebContents(web_contents);
78 } 76 }
79 77
80 if (!content_settings || content_settings->IsBlockageIndicated( 78 if (!content_settings || content_settings->IsBlockageIndicated(
81 content_setting_image_model_->get_content_settings_type())) 79 content_setting_image_model_->get_content_settings_type()))
82 return; 80 return;
83 81
84 // The content blockage was not yet indicated to the user. Start indication 82 // The content blockage was not yet indicated to the user. Start indication
85 // animation and clear "not yet shown" flag. 83 // animation and clear "not yet shown" flag.
86 content_settings->SetBlockageHasBeenIndicated( 84 content_settings->SetBlockageHasBeenIndicated(
87 content_setting_image_model_->get_content_settings_type()); 85 content_setting_image_model_->get_content_settings_type());
(...skipping 25 matching lines...) Expand all
113 void ContentSettingImageView::OnWidgetClosing(views::Widget* widget) { 111 void ContentSettingImageView::OnWidgetClosing(views::Widget* widget) {
114 if (bubble_widget_) { 112 if (bubble_widget_) {
115 bubble_widget_->RemoveObserver(this); 113 bubble_widget_->RemoveObserver(this);
116 bubble_widget_ = NULL; 114 bubble_widget_ = NULL;
117 } 115 }
118 116
119 UnpauseAnimation(); 117 UnpauseAnimation();
120 } 118 }
121 119
122 void ContentSettingImageView::OnClick(LocationBarView* parent) { 120 void ContentSettingImageView::OnClick(LocationBarView* parent) {
123 TabContents* tab_contents = parent->GetTabContents(); 121 WebContents* web_contents = parent->GetWebContents();
124 if (!tab_contents) 122 if (!web_contents)
125 return; 123 return;
126 if (bubble_widget_) 124 if (bubble_widget_)
127 return; 125 return;
128 126
129 Profile* profile = parent->profile(); 127 Profile* profile = parent->profile();
130 ContentSettingBubbleContents* bubble = new ContentSettingBubbleContents( 128 ContentSettingBubbleContents* bubble = new ContentSettingBubbleContents(
131 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 129 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
132 parent->delegate()->GetContentSettingBubbleModelDelegate(), 130 parent->delegate()->GetContentSettingBubbleModelDelegate(),
133 tab_contents->web_contents(), 131 web_contents,
134 profile, 132 profile,
135 content_setting_image_model_->get_content_settings_type()), 133 content_setting_image_model_->get_content_settings_type()),
136 tab_contents->web_contents(), 134 web_contents,
137 this, 135 this,
138 views::BubbleBorder::TOP_RIGHT); 136 views::BubbleBorder::TOP_RIGHT);
139 bubble_widget_ = parent->delegate()->CreateViewsBubble(bubble); 137 bubble_widget_ = parent->delegate()->CreateViewsBubble(bubble);
140 bubble_widget_->AddObserver(this); 138 bubble_widget_->AddObserver(this);
141 bubble->Show(); 139 bubble->Show();
142 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698