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

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

Issue 1414643005: Disable zoom bubble for PDF extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Need to check for valid client before early out. Created 5 years, 2 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/extensions/extension_util.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"
12 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
13 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/views/frame/browser_view.h" 15 #include "chrome/browser/ui/views/frame/browser_view.h"
15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
16 #include "chrome/browser/ui/views/location_bar/zoom_view.h" 17 #include "chrome/browser/ui/views/location_bar/zoom_view.h"
17 #include "chrome/common/extensions/api/extension_action/action_info.h" 18 #include "chrome/common/extensions/api/extension_action/action_info.h"
18 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
19 #include "components/ui/zoom/page_zoom.h" 20 #include "components/ui/zoom/page_zoom.h"
(...skipping 11 matching lines...) Expand all
31 #include "ui/views/layout/grid_layout.h" 32 #include "ui/views/layout/grid_layout.h"
32 #include "ui/views/layout/layout_constants.h" 33 #include "ui/views/layout/layout_constants.h"
33 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
34 35
35 // static 36 // static
36 ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = NULL; 37 ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = NULL;
37 38
38 // static 39 // static
39 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, 40 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents,
40 bool auto_close) { 41 bool auto_close) {
42 // Find the extension that initiated the zoom change, if any.
43 ui_zoom::ZoomController* zoom_controller =
44 ui_zoom::ZoomController::FromWebContents(web_contents);
45 const extensions::ExtensionZoomRequestClient* client =
46 static_cast<const extensions::ExtensionZoomRequestClient*>(
47 zoom_controller->last_client());
48
49 if (auto_close && client &&
50 extensions::util::ZoomWithoutBubble(client->extension())) {
51 return;
52 }
53
41 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 54 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
42 DCHECK(browser && browser->window() && 55 DCHECK(browser && browser->window() &&
43 browser->exclusive_access_manager()->fullscreen_controller()); 56 browser->exclusive_access_manager()->fullscreen_controller());
44 57
45 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); 58 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
46 bool is_fullscreen = browser_view->IsFullscreen(); 59 bool is_fullscreen = browser_view->IsFullscreen();
47 bool anchor_to_view = !is_fullscreen || 60 bool anchor_to_view = !is_fullscreen ||
48 browser_view->immersive_mode_controller()->IsRevealed(); 61 browser_view->immersive_mode_controller()->IsRevealed();
49 views::View* anchor_view = anchor_to_view ? 62 views::View* anchor_view = anchor_to_view ?
50 browser_view->GetLocationBarView()->zoom_view() : NULL; 63 browser_view->GetLocationBarView()->zoom_view() : NULL;
51 64
52 // Find the extension that initiated the zoom change, if any.
53 ui_zoom::ZoomController* zoom_controller =
54 ui_zoom::ZoomController::FromWebContents(web_contents);
55 const ui_zoom::ZoomRequestClient* client = zoom_controller->last_client();
56
57 // If the bubble is already showing in this window and the zoom change was not 65 // If the bubble is already showing in this window and the zoom change was not
58 // initiated by an extension, then the bubble can be reused and only the label 66 // initiated by an extension, then the bubble can be reused and only the label
59 // text needs to be updated. 67 // text needs to be updated.
60 if (zoom_bubble_ && zoom_bubble_->GetAnchorView() == anchor_view && !client) { 68 if (zoom_bubble_ && zoom_bubble_->GetAnchorView() == anchor_view && !client) {
61 DCHECK_EQ(web_contents, zoom_bubble_->web_contents_); 69 DCHECK_EQ(web_contents, zoom_bubble_->web_contents_);
62 zoom_bubble_->Refresh(); 70 zoom_bubble_->Refresh();
63 return; 71 return;
64 } 72 }
65 73
66 // If the bubble is already showing but in a different tab, the current 74 // If the bubble is already showing but in a different tab, the current
67 // bubble must be closed and a new one created. 75 // bubble must be closed and a new one created.
68 CloseBubble(); 76 CloseBubble();
69 77
70 zoom_bubble_ = new ZoomBubbleView(anchor_view, web_contents, auto_close, 78 zoom_bubble_ = new ZoomBubbleView(anchor_view, web_contents, auto_close,
71 browser_view->immersive_mode_controller()); 79 browser_view->immersive_mode_controller());
72 80
73 // If the zoom change was initiated by an extension, capture the relevent 81 // If the zoom change was initiated by an extension, capture the relevent
74 // information from it. 82 // information from it.
75 if (client) { 83 if (client)
76 zoom_bubble_->SetExtensionInfo( 84 zoom_bubble_->SetExtensionInfo(client->extension());
77 static_cast<const extensions::ExtensionZoomRequestClient*>(client)
78 ->extension());
79 }
80 85
81 // If we do not have an anchor view, parent the bubble to the content area. 86 // If we do not have an anchor view, parent the bubble to the content area.
82 if (!anchor_to_view) 87 if (!anchor_to_view)
83 zoom_bubble_->set_parent_window(web_contents->GetNativeView()); 88 zoom_bubble_->set_parent_window(web_contents->GetNativeView());
84 89
85 views::BubbleDelegateView::CreateBubble(zoom_bubble_); 90 views::BubbleDelegateView::CreateBubble(zoom_bubble_);
86 91
87 // Adjust for fullscreen after creation as it relies on the content size. 92 // Adjust for fullscreen after creation as it relies on the content size.
88 if (is_fullscreen) 93 if (is_fullscreen)
89 zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen()); 94 zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen());
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 319 }
315 } 320 }
316 321
317 void ZoomBubbleView::StopTimer() { 322 void ZoomBubbleView::StopTimer() {
318 timer_.Stop(); 323 timer_.Stop();
319 } 324 }
320 325
321 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} 326 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {}
322 327
323 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} 328 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698