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

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

Powered by Google App Engine
This is Rietveld 408576698