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

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

Issue 836933005: Refactor fullscreen_controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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/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 "base/strings/stringprintf.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/chrome_page_zoom.h" 10 #include "chrome/browser/chrome_page_zoom.h"
(...skipping 21 matching lines...) Expand all
32 #include "ui/views/layout/layout_constants.h" 32 #include "ui/views/layout/layout_constants.h"
33 #include "ui/views/widget/widget.h" 33 #include "ui/views/widget/widget.h"
34 34
35 // static 35 // static
36 ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = NULL; 36 ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = NULL;
37 37
38 // static 38 // static
39 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, 39 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents,
40 bool auto_close) { 40 bool auto_close) {
41 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 41 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
42 DCHECK(browser && browser->window() && browser->fullscreen_controller()); 42 DCHECK(browser && browser->window() &&
43 browser->GetExclusiveAccessControllerManager()
44 ->GetFullscreenController());
43 45
44 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); 46 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
45 bool is_fullscreen = browser_view->IsFullscreen(); 47 bool is_fullscreen = browser_view->IsFullscreen();
46 bool anchor_to_view = !is_fullscreen || 48 bool anchor_to_view = !is_fullscreen ||
47 browser_view->immersive_mode_controller()->IsRevealed(); 49 browser_view->immersive_mode_controller()->IsRevealed();
48 views::View* anchor_view = anchor_to_view ? 50 views::View* anchor_view = anchor_to_view ?
49 browser_view->GetLocationBarView()->zoom_view() : NULL; 51 browser_view->GetLocationBarView()->zoom_view() : NULL;
50 52
51 // Find the extension that initiated the zoom change, if any. 53 // Find the extension that initiated the zoom change, if any.
52 ui_zoom::ZoomController* zoom_controller = 54 ui_zoom::ZoomController* zoom_controller =
53 ui_zoom::ZoomController::FromWebContents(web_contents); 55 ui_zoom::ZoomController::FromWebContents(web_contents);
54 const ui_zoom::ZoomRequestClient* client = zoom_controller->last_client(); 56 const ui_zoom::ZoomRequestClient* client = zoom_controller->last_client();
55 57
56 // If the bubble is already showing in this window and the zoom change was not 58 // If the bubble is already showing in this window and the zoom change was not
57 // initiated by an extension, then the bubble can be reused and only the label 59 // initiated by an extension, then the bubble can be reused and only the label
58 // text needs to be updated. 60 // text needs to be updated.
59 if (zoom_bubble_ && zoom_bubble_->GetAnchorView() == anchor_view && !client) { 61 if (zoom_bubble_ && zoom_bubble_->GetAnchorView() == anchor_view && !client) {
60 DCHECK_EQ(web_contents, zoom_bubble_->web_contents_); 62 DCHECK_EQ(web_contents, zoom_bubble_->web_contents_);
61 zoom_bubble_->Refresh(); 63 zoom_bubble_->Refresh();
62 return; 64 return;
63 } 65 }
64 66
65 // If the bubble is already showing but in a different tab, the current 67 // If the bubble is already showing but in a different tab, the current
66 // bubble must be closed and a new one created. 68 // bubble must be closed and a new one created.
67 CloseBubble(); 69 CloseBubble();
68 70
69 zoom_bubble_ = new ZoomBubbleView(anchor_view, 71 zoom_bubble_ = new ZoomBubbleView(anchor_view, web_contents, auto_close,
70 web_contents, 72 browser_view->immersive_mode_controller());
71 auto_close,
72 browser_view->immersive_mode_controller(),
73 browser->fullscreen_controller());
74 73
75 // If the zoom change was initiated by an extension, capture the relevent 74 // If the zoom change was initiated by an extension, capture the relevent
76 // information from it. 75 // information from it.
77 if (client) { 76 if (client) {
78 zoom_bubble_->SetExtensionInfo( 77 zoom_bubble_->SetExtensionInfo(
79 static_cast<const extensions::ExtensionZoomRequestClient*>(client) 78 static_cast<const extensions::ExtensionZoomRequestClient*>(client)
80 ->extension()); 79 ->extension());
81 } 80 }
82 81
83 // If we do not have an anchor view, parent the bubble to the content area. 82 // If we do not have an anchor view, parent the bubble to the content area.
(...skipping 27 matching lines...) Expand all
111 110
112 // static 111 // static
113 const ZoomBubbleView* ZoomBubbleView::GetZoomBubbleForTest() { 112 const ZoomBubbleView* ZoomBubbleView::GetZoomBubbleForTest() {
114 return zoom_bubble_; 113 return zoom_bubble_;
115 } 114 }
116 115
117 ZoomBubbleView::ZoomBubbleView( 116 ZoomBubbleView::ZoomBubbleView(
118 views::View* anchor_view, 117 views::View* anchor_view,
119 content::WebContents* web_contents, 118 content::WebContents* web_contents,
120 bool auto_close, 119 bool auto_close,
121 ImmersiveModeController* immersive_mode_controller, 120 ImmersiveModeController* immersive_mode_controller)
122 FullscreenController* fullscreen_controller)
123 : ManagedFullScreenBubbleDelegateView(anchor_view, web_contents), 121 : ManagedFullScreenBubbleDelegateView(anchor_view, web_contents),
124 image_button_(NULL), 122 image_button_(NULL),
125 label_(NULL), 123 label_(NULL),
126 web_contents_(web_contents), 124 web_contents_(web_contents),
127 auto_close_(auto_close), 125 auto_close_(auto_close),
128 immersive_mode_controller_(immersive_mode_controller) { 126 immersive_mode_controller_(immersive_mode_controller) {
129 // Compensate for built-in vertical padding in the anchor view's image. 127 // Compensate for built-in vertical padding in the anchor view's image.
130 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); 128 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
131 set_notify_enter_exit_on_child(true); 129 set_notify_enter_exit_on_child(true);
132 immersive_mode_controller_->AddObserver(this); 130 immersive_mode_controller_->AddObserver(this);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 322 }
325 } 323 }
326 324
327 void ZoomBubbleView::StopTimer() { 325 void ZoomBubbleView::StopTimer() {
328 timer_.Stop(); 326 timer_.Stop();
329 } 327 }
330 328
331 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} 329 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {}
332 330
333 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} 331 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698