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

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

Issue 7574021: Remove frontend code that allows for dynamic profile setting, and read the profile off the browse... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser.h"
9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" 13 #include "chrome/browser/ui/views/content_setting_bubble_contents.h"
13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
14 #include "content/browser/tab_contents/tab_contents.h" 15 #include "content/browser/tab_contents/tab_contents.h"
15 #include "third_party/skia/include/core/SkShader.h" 16 #include "third_party/skia/include/core/SkShader.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
(...skipping 19 matching lines...) Expand all
38 39
39 40
40 // The fraction of the animation we'll spend animating the string into view, and 41 // The fraction of the animation we'll spend animating the string into view, and
41 // then again animating it closed - total animation (slide out, show, then 42 // then again animating it closed - total animation (slide out, show, then
42 // slide in) is 1.0. 43 // slide in) is 1.0.
43 const double kAnimatingFraction = kOpenTimeMs * 1.0 / kMoveTimeMs; 44 const double kAnimatingFraction = kOpenTimeMs * 1.0 / kMoveTimeMs;
44 } 45 }
45 46
46 ContentSettingImageView::ContentSettingImageView( 47 ContentSettingImageView::ContentSettingImageView(
47 ContentSettingsType content_type, 48 ContentSettingsType content_type,
48 LocationBarView* parent, 49 LocationBarView* parent)
49 Profile* profile)
50 : ui::LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL), 50 : ui::LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL),
51 content_setting_image_model_( 51 content_setting_image_model_(
52 ContentSettingImageModel::CreateContentSettingImageModel( 52 ContentSettingImageModel::CreateContentSettingImageModel(
53 content_type)), 53 content_type)),
54 parent_(parent), 54 parent_(parent),
55 profile_(profile),
56 bubble_(NULL), 55 bubble_(NULL),
57 animation_in_progress_(false), 56 animation_in_progress_(false),
58 text_size_(0), 57 text_size_(0),
59 visible_text_size_(0) { 58 visible_text_size_(0) {
60 SetHorizontalAlignment(ImageView::LEADING); 59 SetHorizontalAlignment(ImageView::LEADING);
61 } 60 }
62 61
63 ContentSettingImageView::~ContentSettingImageView() { 62 ContentSettingImageView::~ContentSettingImageView() {
64 if (bubble_) 63 if (bubble_)
65 bubble_->Close(); 64 bubble_->Close();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return; 128 return;
130 129
131 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); 130 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper();
132 if (!tab_contents) 131 if (!tab_contents)
133 return; 132 return;
134 133
135 gfx::Rect screen_bounds(GetImageBounds()); 134 gfx::Rect screen_bounds(GetImageBounds());
136 gfx::Point origin(screen_bounds.origin()); 135 gfx::Point origin(screen_bounds.origin());
137 views::View::ConvertPointToScreen(this, &origin); 136 views::View::ConvertPointToScreen(this, &origin);
138 screen_bounds.set_origin(origin); 137 screen_bounds.set_origin(origin);
138 Profile* profile = parent_->browser()->profile();
139 ContentSettingBubbleContents* bubble_contents = 139 ContentSettingBubbleContents* bubble_contents =
140 new ContentSettingBubbleContents( 140 new ContentSettingBubbleContents(
141 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 141 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
142 parent_->browser(), tab_contents, profile_, 142 parent_->browser(), tab_contents, profile,
143 content_setting_image_model_->get_content_settings_type()), 143 content_setting_image_model_->get_content_settings_type()),
144 profile_, tab_contents->tab_contents()); 144 profile, tab_contents->tab_contents());
145 bubble_ = Bubble::Show(GetWidget(), screen_bounds, BubbleBorder::TOP_RIGHT, 145 bubble_ = Bubble::Show(GetWidget(), screen_bounds, BubbleBorder::TOP_RIGHT,
146 bubble_contents, this); 146 bubble_contents, this);
147 bubble_contents->set_bubble(bubble_); 147 bubble_contents->set_bubble(bubble_);
148 } 148 }
149 149
150 void ContentSettingImageView::VisibilityChanged(View* starting_from, 150 void ContentSettingImageView::VisibilityChanged(View* starting_from,
151 bool is_visible) { 151 bool is_visible) {
152 if (!is_visible && bubble_) 152 if (!is_visible && bubble_)
153 bubble_->Close(); 153 bubble_->Close();
154 } 154 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } else if (state > (1.0 - kAnimatingFraction)) { 236 } else if (state > (1.0 - kAnimatingFraction)) {
237 visible_text_size_ = static_cast<int>(text_size_ * (1.0 - state) / 237 visible_text_size_ = static_cast<int>(text_size_ * (1.0 - state) /
238 kAnimatingFraction); 238 kAnimatingFraction);
239 } else { 239 } else {
240 visible_text_size_ = text_size_; 240 visible_text_size_ = text_size_;
241 } 241 }
242 parent_->Layout(); 242 parent_->Layout();
243 parent_->SchedulePaint(); 243 parent_->SchedulePaint();
244 } 244 }
245 245
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698