Chromium Code Reviews| 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/zoom_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/strings/stringprintf.h" | |
| 8 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/chrome_page_zoom.h" | 10 #include "chrome/browser/chrome_page_zoom.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/browser_tabstrip.h" | |
| 12 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 15 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 17 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
| 16 #include "chrome/browser/ui/zoom/zoom_controller.h" | 18 #include "chrome/browser/ui/zoom/zoom_controller.h" |
| 19 #include "chrome/common/extensions/api/extension_action/action_info.h" | |
| 17 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 21 #include "extensions/common/manifest_handlers/icons_handler.h" | |
| 18 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 23 #include "grit/theme_resources.h" | |
| 19 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/gfx/favicon_size.h" | |
| 27 #include "ui/views/controls/button/image_button.h" | |
| 21 #include "ui/views/controls/button/label_button.h" | 28 #include "ui/views/controls/button/label_button.h" |
| 22 #include "ui/views/controls/separator.h" | 29 #include "ui/views/controls/separator.h" |
| 23 #include "ui/views/layout/box_layout.h" | 30 #include "ui/views/layout/grid_layout.h" |
| 24 #include "ui/views/layout/layout_constants.h" | 31 #include "ui/views/layout/layout_constants.h" |
| 25 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
| 26 | 33 |
| 27 namespace { | 34 namespace { |
| 28 | 35 |
| 29 // The number of milliseconds the bubble should stay on the screen if it will | 36 // The number of milliseconds the bubble should stay on the screen if it will |
| 30 // close automatically. | 37 // close automatically. |
| 31 const int kBubbleCloseDelay = 1500; | 38 const int kBubbleCloseDelay = 1500; |
| 32 | 39 |
| 33 // The bubble's padding from the screen edge, used in fullscreen. | 40 // The bubble's padding from the screen edge, used in fullscreen. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 44 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 51 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 45 DCHECK(browser && browser->window() && browser->fullscreen_controller()); | 52 DCHECK(browser && browser->window() && browser->fullscreen_controller()); |
| 46 | 53 |
| 47 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 54 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 48 bool is_fullscreen = browser_view->IsFullscreen(); | 55 bool is_fullscreen = browser_view->IsFullscreen(); |
| 49 bool anchor_to_view = !is_fullscreen || | 56 bool anchor_to_view = !is_fullscreen || |
| 50 browser_view->immersive_mode_controller()->IsRevealed(); | 57 browser_view->immersive_mode_controller()->IsRevealed(); |
| 51 views::View* anchor_view = anchor_to_view ? | 58 views::View* anchor_view = anchor_to_view ? |
| 52 browser_view->GetLocationBarView()->zoom_view() : NULL; | 59 browser_view->GetLocationBarView()->zoom_view() : NULL; |
| 53 | 60 |
| 54 // If the bubble is already showing in this window and its |auto_close_| value | 61 // Find the extension that initiated the zoom change, if any. |
| 55 // is equal to |auto_close|, the bubble can be reused and only the label text | 62 ZoomController* zoom_controller = |
| 56 // needs to be updated. | 63 ZoomController::FromWebContents(web_contents); |
| 64 const extensions::Extension* extension = zoom_controller->last_extension(); | |
| 65 | |
| 66 // If the bubble is already showing in this window, its |auto_close_| value | |
| 67 // is equal to |auto_close|, and the zoom change was not initiated by an | |
| 68 // extension, then the bubble can be reused and only the label text needs to | |
| 69 // be updated. | |
| 57 if (zoom_bubble_ && | 70 if (zoom_bubble_ && |
| 58 zoom_bubble_->GetAnchorView() == anchor_view && | 71 zoom_bubble_->GetAnchorView() == anchor_view && |
| 59 zoom_bubble_->auto_close_ == auto_close) { | 72 zoom_bubble_->auto_close_ == auto_close && |
| 73 !extension) { | |
| 60 zoom_bubble_->Refresh(); | 74 zoom_bubble_->Refresh(); |
| 61 } else { | 75 return; |
| 62 // If the bubble is already showing but its |auto_close_| value is not equal | 76 } |
| 63 // to |auto_close|, the bubble's focus properties must change, so the | |
| 64 // current bubble must be closed and a new one created. | |
| 65 CloseBubble(); | |
| 66 | 77 |
| 67 zoom_bubble_ = new ZoomBubbleView(anchor_view, | 78 // If the bubble is already showing but its |auto_close_| value is not equal |
| 68 web_contents, | 79 // to |auto_close|, the bubble's focus properties must change, so the |
| 69 auto_close, | 80 // current bubble must be closed and a new one created. |
| 70 browser_view->immersive_mode_controller(), | 81 CloseBubble(); |
| 71 browser->fullscreen_controller()); | |
| 72 | 82 |
| 73 // If we do not have an anchor view, parent the bubble to the content area. | 83 zoom_bubble_ = new ZoomBubbleView(anchor_view, |
| 74 if (!anchor_to_view) { | 84 web_contents, |
| 75 zoom_bubble_->set_parent_window(web_contents->GetTopLevelNativeWindow()); | 85 auto_close, |
| 76 } | 86 browser_view->immersive_mode_controller(), |
| 87 browser->fullscreen_controller()); | |
| 77 | 88 |
| 78 views::BubbleDelegateView::CreateBubble(zoom_bubble_); | 89 // If the zoom change was initiated by an extension, capture the relevent |
| 90 // information from it. | |
| 91 if (extension) | |
| 92 zoom_bubble_->SetExtensionInfo(extension); | |
| 79 | 93 |
| 80 // Adjust for fullscreen after creation as it relies on the content size. | 94 // If we do not have an anchor view, parent the bubble to the content area. |
| 81 if (is_fullscreen) | 95 if (!anchor_to_view) |
| 82 zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen()); | 96 zoom_bubble_->set_parent_window(web_contents->GetTopLevelNativeWindow()); |
| 83 | 97 |
| 84 if (zoom_bubble_->use_focusless()) | 98 views::BubbleDelegateView::CreateBubble(zoom_bubble_); |
| 85 zoom_bubble_->GetWidget()->ShowInactive(); | 99 |
| 86 else | 100 // Adjust for fullscreen after creation as it relies on the content size. |
| 87 zoom_bubble_->GetWidget()->Show(); | 101 if (is_fullscreen) |
| 88 } | 102 zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen()); |
| 103 | |
| 104 if (zoom_bubble_->use_focusless()) | |
| 105 zoom_bubble_->GetWidget()->ShowInactive(); | |
| 106 else | |
| 107 zoom_bubble_->GetWidget()->Show(); | |
| 89 } | 108 } |
| 90 | 109 |
| 91 // static | 110 // static |
| 92 void ZoomBubbleView::CloseBubble() { | 111 void ZoomBubbleView::CloseBubble() { |
| 93 if (zoom_bubble_) | 112 if (zoom_bubble_) |
| 94 zoom_bubble_->Close(); | 113 zoom_bubble_->Close(); |
| 95 } | 114 } |
| 96 | 115 |
| 97 // static | 116 // static |
| 98 bool ZoomBubbleView::IsShowing() { | 117 bool ZoomBubbleView::IsShowing() { |
| 99 // The bubble may be in the process of closing. | 118 // The bubble may be in the process of closing. |
| 100 return zoom_bubble_ != NULL && zoom_bubble_->GetWidget()->IsVisible(); | 119 return zoom_bubble_ != NULL && zoom_bubble_->GetWidget()->IsVisible(); |
| 101 } | 120 } |
| 102 | 121 |
| 103 // static | 122 // static |
| 104 const ZoomBubbleView* ZoomBubbleView::GetZoomBubbleForTest() { | 123 const ZoomBubbleView* ZoomBubbleView::GetZoomBubbleForTest() { |
| 105 return zoom_bubble_; | 124 return zoom_bubble_; |
| 106 } | 125 } |
| 107 | 126 |
| 108 ZoomBubbleView::ZoomBubbleView( | 127 ZoomBubbleView::ZoomBubbleView( |
| 109 views::View* anchor_view, | 128 views::View* anchor_view, |
| 110 content::WebContents* web_contents, | 129 content::WebContents* web_contents, |
| 111 bool auto_close, | 130 bool auto_close, |
| 112 ImmersiveModeController* immersive_mode_controller, | 131 ImmersiveModeController* immersive_mode_controller, |
| 113 FullscreenController* fullscreen_controller) | 132 FullscreenController* fullscreen_controller) |
| 114 : BubbleDelegateView(anchor_view, anchor_view ? | 133 : BubbleDelegateView(anchor_view, anchor_view ? |
| 115 views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE), | 134 views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE), |
| 135 image_button_(NULL), | |
| 116 label_(NULL), | 136 label_(NULL), |
| 117 web_contents_(web_contents), | 137 web_contents_(web_contents), |
| 118 auto_close_(auto_close), | 138 auto_close_(auto_close), |
| 119 immersive_mode_controller_(immersive_mode_controller) { | 139 immersive_mode_controller_(immersive_mode_controller) { |
| 120 // Compensate for built-in vertical padding in the anchor view's image. | 140 // Compensate for built-in vertical padding in the anchor view's image. |
| 121 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 141 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
| 122 set_use_focusless(auto_close); | 142 set_use_focusless(auto_close); |
| 123 set_notify_enter_exit_on_child(true); | 143 set_notify_enter_exit_on_child(true); |
| 124 | 144 |
| 125 // Add observers to close the bubble if the fullscreen state or immersive | 145 // Add observers to close the bubble if the fullscreen state or immersive |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 143 const size_t bubble_half_width = width() / 2; | 163 const size_t bubble_half_width = width() / 2; |
| 144 const int x_pos = base::i18n::IsRTL() ? | 164 const int x_pos = base::i18n::IsRTL() ? |
| 145 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : | 165 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : |
| 146 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; | 166 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; |
| 147 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | 167 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
| 148 } | 168 } |
| 149 | 169 |
| 150 void ZoomBubbleView::Refresh() { | 170 void ZoomBubbleView::Refresh() { |
| 151 ZoomController* zoom_controller = | 171 ZoomController* zoom_controller = |
| 152 ZoomController::FromWebContents(web_contents_); | 172 ZoomController::FromWebContents(web_contents_); |
| 153 int zoom_percent = zoom_controller->zoom_percent(); | 173 int zoom_percent = zoom_controller->GetZoomPercent(); |
| 154 label_->SetText( | 174 label_->SetText( |
| 155 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); | 175 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); |
| 156 StartTimerIfNecessary(); | 176 StartTimerIfNecessary(); |
| 157 } | 177 } |
| 158 | 178 |
| 159 void ZoomBubbleView::Close() { | 179 void ZoomBubbleView::Close() { |
| 160 GetWidget()->Close(); | 180 GetWidget()->Close(); |
| 161 } | 181 } |
| 162 | 182 |
| 183 void ZoomBubbleView::SetExtensionInfo(const extensions::Extension* extension) { | |
| 184 DCHECK(extension); | |
| 185 extension_info_.id = extension->id(); | |
| 186 extension_info_.name = extension->name(); | |
| 187 | |
| 188 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 189 const gfx::ImageSkia& default_extension_icon_image = | |
| 190 *rb.GetImageSkiaNamed(IDR_EXTENSIONS_FAVICON); | |
| 191 int icon_size = gfx::kFaviconSize; | |
| 192 | |
| 193 // We give first preference to an icon from the extension's icon set that | |
| 194 // matches the size of the default. But not all extensions will declare an | |
| 195 // icon set, or may not have an icon of the default size (we don't want the | |
| 196 // bubble to display, for example, a very large icon). In that case, if there | |
| 197 // is a browser-action icon (size-19) this is an acceptable alternative. | |
| 198 const ExtensionIconSet& icons = extensions::IconsInfo::GetIcons(extension); | |
| 199 bool has_default_sized_icon = | |
| 200 !icons.Get(gfx::kFaviconSize, ExtensionIconSet::MATCH_EXACTLY).empty(); | |
| 201 if (has_default_sized_icon) { | |
| 202 extension_info_.icon_image.reset( | |
| 203 new extensions::IconImage(web_contents_->GetBrowserContext(), | |
| 204 extension, | |
| 205 icons, | |
| 206 icon_size, | |
| 207 default_extension_icon_image, | |
| 208 this)); | |
| 209 return; | |
| 210 } | |
| 211 | |
| 212 const extensions::ActionInfo* browser_action = | |
| 213 extensions::ActionInfo::GetBrowserActionInfo(extension); | |
| 214 if (!browser_action || browser_action->default_icon.empty()) | |
| 215 return; | |
| 216 | |
| 217 icon_size = browser_action->default_icon.map().begin()->first; | |
| 218 extension_info_.icon_image.reset( | |
| 219 new extensions::IconImage(web_contents_->GetBrowserContext(), | |
| 220 extension, | |
| 221 browser_action->default_icon, | |
| 222 icon_size, | |
| 223 default_extension_icon_image, | |
| 224 this)); | |
| 225 } | |
| 226 | |
| 163 void ZoomBubbleView::StartTimerIfNecessary() { | 227 void ZoomBubbleView::StartTimerIfNecessary() { |
| 164 if (auto_close_) { | 228 if (auto_close_) { |
| 165 if (timer_.IsRunning()) { | 229 if (timer_.IsRunning()) { |
| 166 timer_.Reset(); | 230 timer_.Reset(); |
| 167 } else { | 231 } else { |
| 168 timer_.Start( | 232 timer_.Start( |
| 169 FROM_HERE, | 233 FROM_HERE, |
| 170 base::TimeDelta::FromMilliseconds(kBubbleCloseDelay), | 234 base::TimeDelta::FromMilliseconds(kBubbleCloseDelay), |
| 171 this, | 235 this, |
| 172 &ZoomBubbleView::Close); | 236 &ZoomBubbleView::Close); |
| 173 } | 237 } |
| 174 } | 238 } |
| 175 } | 239 } |
| 176 | 240 |
| 177 void ZoomBubbleView::StopTimer() { | 241 void ZoomBubbleView::StopTimer() { |
| 178 timer_.Stop(); | 242 timer_.Stop(); |
| 179 } | 243 } |
| 180 | 244 |
| 245 void ZoomBubbleView::OnExtensionIconImageChanged(extensions::IconImage* image) { | |
| 246 DCHECK_EQ(image, extension_info_.icon_image.get()) << | |
| 247 "Unknown ImageIcon update."; | |
| 248 image_button_->SetPreferredSize( | |
|
sky
2014/06/25 21:02:42
Now I'm slightly confused. As long as the image he
wjmaclean
2014/06/25 21:12:19
By the time SetImage() is called, we do have a def
| |
| 249 extension_info_.icon_image->image_skia().size()); | |
| 250 image_button_->SetImage(views::Button::STATE_NORMAL, | |
| 251 &extension_info_.icon_image->image_skia()); | |
| 252 image_button_->SchedulePaint(); | |
| 253 } | |
| 254 | |
| 181 void ZoomBubbleView::OnMouseEntered(const ui::MouseEvent& event) { | 255 void ZoomBubbleView::OnMouseEntered(const ui::MouseEvent& event) { |
| 182 set_use_focusless(false); | 256 set_use_focusless(false); |
| 183 StopTimer(); | 257 StopTimer(); |
| 184 } | 258 } |
| 185 | 259 |
| 186 void ZoomBubbleView::OnMouseExited(const ui::MouseEvent& event) { | 260 void ZoomBubbleView::OnMouseExited(const ui::MouseEvent& event) { |
| 187 set_use_focusless(auto_close_); | 261 set_use_focusless(auto_close_); |
| 188 StartTimerIfNecessary(); | 262 StartTimerIfNecessary(); |
| 189 } | 263 } |
| 190 | 264 |
| 191 void ZoomBubbleView::OnGestureEvent(ui::GestureEvent* event) { | 265 void ZoomBubbleView::OnGestureEvent(ui::GestureEvent* event) { |
| 192 if (!zoom_bubble_ || !zoom_bubble_->auto_close_ || | 266 if (!zoom_bubble_ || !zoom_bubble_->auto_close_ || |
| 193 event->type() != ui::ET_GESTURE_TAP) { | 267 event->type() != ui::ET_GESTURE_TAP) { |
| 194 return; | 268 return; |
| 195 } | 269 } |
| 196 | 270 |
| 197 // If an auto-closing bubble was tapped, show a non-auto-closing bubble in | 271 // If an auto-closing bubble was tapped, show a non-auto-closing bubble in |
| 198 // its place. | 272 // its place. |
| 199 ShowBubble(zoom_bubble_->web_contents_, false); | 273 ShowBubble(zoom_bubble_->web_contents_, false); |
| 200 event->SetHandled(); | 274 event->SetHandled(); |
| 201 } | 275 } |
| 202 | 276 |
| 203 void ZoomBubbleView::ButtonPressed(views::Button* sender, | 277 void ZoomBubbleView::ButtonPressed(views::Button* sender, |
| 204 const ui::Event& event) { | 278 const ui::Event& event) { |
| 205 chrome_page_zoom::Zoom(web_contents_, content::PAGE_ZOOM_RESET); | 279 if (sender == image_button_) { |
| 280 DCHECK(extension_info_.icon_image.get()) << "Invalid button press."; | |
| 281 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | |
| 282 chrome::AddSelectedTabWithURL( | |
| 283 browser, | |
| 284 GURL(base::StringPrintf("chrome://extensions?id=%s", | |
| 285 extension_info_.id.c_str())), | |
| 286 content::PAGE_TRANSITION_FROM_API); | |
| 287 } else { | |
| 288 chrome_page_zoom::Zoom(web_contents_, content::PAGE_ZOOM_RESET); | |
| 289 } | |
| 206 } | 290 } |
| 207 | 291 |
| 208 void ZoomBubbleView::Init() { | 292 void ZoomBubbleView::Init() { |
| 209 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, | 293 // Set up the layout of the zoom bubble. A grid layout is used because |
| 210 0, 0, views::kRelatedControlVerticalSpacing)); | 294 // sometimes an extension icon is shown next to the zoom label. |
| 295 views::GridLayout* grid_layout = new views::GridLayout(this); | |
| 296 SetLayoutManager(grid_layout); | |
| 297 views::ColumnSet* columns = grid_layout->AddColumnSet(0); | |
| 298 // First row. | |
| 299 if (extension_info_.icon_image.get()) { | |
| 300 columns->AddColumn(views::GridLayout::CENTER,views::GridLayout::CENTER, 2, | |
| 301 views::GridLayout::USE_PREF, 0, 0); | |
| 302 } | |
| 303 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | |
| 304 views::GridLayout::USE_PREF, 0, 0); | |
| 305 grid_layout->StartRow(0, 0); | |
| 211 | 306 |
| 307 // If this zoom change was initiated by an extension, that extension will be | |
| 308 // attributed by showing its icon in the zoom bubble. | |
| 309 if (extension_info_.icon_image.get()) { | |
| 310 image_button_ = new views::ImageButton(this); | |
| 311 image_button_->SetTooltipText(l10n_util::GetStringFUTF16( | |
| 312 IDS_TOOLTIP_ZOOM_EXTENSION_ICON, | |
| 313 base::UTF8ToUTF16(extension_info_.name))); | |
| 314 image_button_->SetPreferredSize( | |
| 315 extension_info_.icon_image->image_skia().size()); | |
| 316 image_button_->SetImage(views::Button::STATE_NORMAL, | |
| 317 &extension_info_.icon_image->image_skia()); | |
| 318 grid_layout->AddView(image_button_); | |
| 319 } | |
| 320 | |
| 321 // Add zoom label with the new zoom percent. | |
| 212 ZoomController* zoom_controller = | 322 ZoomController* zoom_controller = |
| 213 ZoomController::FromWebContents(web_contents_); | 323 ZoomController::FromWebContents(web_contents_); |
| 214 int zoom_percent = zoom_controller->zoom_percent(); | 324 int zoom_percent = zoom_controller->GetZoomPercent(); |
| 215 label_ = new views::Label( | 325 label_ = new views::Label( |
| 216 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); | 326 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); |
| 217 label_->SetFontList( | 327 label_->SetFontList( |
| 218 ui::ResourceBundle::GetSharedInstance().GetFontList( | 328 ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 219 ui::ResourceBundle::MediumFont)); | 329 ui::ResourceBundle::MediumFont)); |
| 220 AddChildView(label_); | 330 grid_layout->AddView(label_); |
| 221 | 331 |
| 332 // Second row. | |
| 333 grid_layout->AddPaddingRow(0, 8); | |
| 334 columns = grid_layout->AddColumnSet(1); | |
| 335 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | |
| 336 views::GridLayout::USE_PREF, 0, 0); | |
| 337 grid_layout->StartRow(0, 1); | |
| 338 | |
| 339 // Add "Reset to Default" button. | |
| 222 views::LabelButton* set_default_button = new views::LabelButton( | 340 views::LabelButton* set_default_button = new views::LabelButton( |
| 223 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT)); | 341 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT)); |
| 224 set_default_button->SetStyle(views::Button::STYLE_BUTTON); | 342 set_default_button->SetStyle(views::Button::STYLE_BUTTON); |
| 225 set_default_button->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 343 set_default_button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 226 AddChildView(set_default_button); | 344 grid_layout->AddView(set_default_button); |
| 227 | 345 |
| 228 StartTimerIfNecessary(); | 346 StartTimerIfNecessary(); |
| 229 } | 347 } |
| 230 | 348 |
| 231 void ZoomBubbleView::Observe(int type, | 349 void ZoomBubbleView::Observe(int type, |
| 232 const content::NotificationSource& source, | 350 const content::NotificationSource& source, |
| 233 const content::NotificationDetails& details) { | 351 const content::NotificationDetails& details) { |
| 234 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | 352 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); |
| 235 CloseBubble(); | 353 CloseBubble(); |
| 236 } | 354 } |
| 237 | 355 |
| 238 void ZoomBubbleView::OnImmersiveRevealStarted() { | 356 void ZoomBubbleView::OnImmersiveRevealStarted() { |
| 239 CloseBubble(); | 357 CloseBubble(); |
| 240 } | 358 } |
| 241 | 359 |
| 242 void ZoomBubbleView::OnImmersiveModeControllerDestroyed() { | 360 void ZoomBubbleView::OnImmersiveModeControllerDestroyed() { |
| 243 immersive_mode_controller_ = NULL; | 361 immersive_mode_controller_ = NULL; |
| 244 } | 362 } |
| 245 | 363 |
| 246 void ZoomBubbleView::WindowClosing() { | 364 void ZoomBubbleView::WindowClosing() { |
| 247 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't | 365 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't |
| 248 // call this right away). Only set to NULL when it's this bubble. | 366 // call this right away). Only set to NULL when it's this bubble. |
| 249 if (zoom_bubble_ == this) | 367 if (zoom_bubble_ == this) |
| 250 zoom_bubble_ = NULL; | 368 zoom_bubble_ = NULL; |
| 251 } | 369 } |
| 370 | |
| 371 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} | |
| 372 | |
| 373 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} | |
| OLD | NEW |