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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_popup.cc

Issue 17293003: Reveal the top-of-window views upon opening an extension popup via a shortcut key in immersive mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_popup.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/extension_popup.h" 5 #include "chrome/browser/ui/views/extensions/extension_popup.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/devtools/devtools_window.h" 9 #include "chrome/browser/devtools/devtools_window.h"
10 #include "chrome/browser/extensions/extension_process_manager.h" 10 #include "chrome/browser/extensions/extension_process_manager.h"
11 #include "chrome/browser/extensions/extension_system.h" 11 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/platform_util.h" 12 #include "chrome/browser/platform_util.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
18 #include "chrome/browser/ui/views/frame/top_container_view.h"
16 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
17 #include "content/public/browser/devtools_agent_host.h" 20 #include "content/public/browser/devtools_agent_host.h"
18 #include "content/public/browser/devtools_manager.h" 21 #include "content/public/browser/devtools_manager.h"
19 #include "content/public/browser/notification_details.h" 22 #include "content/public/browser/notification_details.h"
20 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
21 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
22 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_contents_view.h" 26 #include "content/public/browser/web_contents_view.h"
24 #include "ui/gfx/insets.h" 27 #include "ui/gfx/insets.h"
25 #include "ui/views/layout/fill_layout.h" 28 #include "ui/views/layout/fill_layout.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 const int ExtensionPopup::kMinHeight = 25; 63 const int ExtensionPopup::kMinHeight = 25;
61 const int ExtensionPopup::kMaxWidth = 800; 64 const int ExtensionPopup::kMaxWidth = 800;
62 const int ExtensionPopup::kMaxHeight = 600; 65 const int ExtensionPopup::kMaxHeight = 600;
63 66
64 ExtensionPopup::ExtensionPopup(Browser* browser, 67 ExtensionPopup::ExtensionPopup(Browser* browser,
65 extensions::ExtensionHost* host, 68 extensions::ExtensionHost* host,
66 views::View* anchor_view, 69 views::View* anchor_view,
67 views::BubbleBorder::Arrow arrow, 70 views::BubbleBorder::Arrow arrow,
68 ShowAction show_action) 71 ShowAction show_action)
69 : BubbleDelegateView(anchor_view, arrow), 72 : BubbleDelegateView(anchor_view, arrow),
73 browser_(browser),
70 extension_host_(host), 74 extension_host_(host),
71 devtools_callback_(base::Bind( 75 devtools_callback_(base::Bind(
72 &ExtensionPopup::OnDevToolsStateChanged, base::Unretained(this))) { 76 &ExtensionPopup::OnDevToolsStateChanged, base::Unretained(this))) {
73 inspect_with_devtools_ = show_action == SHOW_AND_INSPECT; 77 inspect_with_devtools_ = show_action == SHOW_AND_INSPECT;
74 // Adjust the margin so that contents fit better. 78 // Adjust the margin so that contents fit better.
75 const int margin = views::BubbleBorder::GetCornerRadius() / 2; 79 const int margin = views::BubbleBorder::GetCornerRadius() / 2;
76 set_margins(gfx::Insets(margin, margin, margin, margin)); 80 set_margins(gfx::Insets(margin, margin, margin, margin));
77 SetLayoutManager(new views::FillLayout()); 81 SetLayoutManager(new views::FillLayout());
78 AddChildView(host->view()); 82 AddChildView(host->view());
79 host->view()->SetContainer(this); 83 host->view()->SetContainer(this);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 190
187 // If the host had somehow finished loading, then we'd miss the notification 191 // If the host had somehow finished loading, then we'd miss the notification
188 // and not show. This seems to happen in single-process mode. 192 // and not show. This seems to happen in single-process mode.
189 if (host->did_stop_loading()) 193 if (host->did_stop_loading())
190 popup->ShowBubble(); 194 popup->ShowBubble();
191 195
192 return popup; 196 return popup;
193 } 197 }
194 198
195 void ExtensionPopup::ShowBubble() { 199 void ExtensionPopup::ShowBubble() {
200 BrowserView* browser_view = browser_ ?
201 BrowserView::GetBrowserViewForBrowser(browser_) : NULL;
202 scoped_ptr<ImmersiveRevealedLock> immersive_reveal_lock;
203 if (browser_view &&
204 browser_view->top_container()->Contains(anchor_view())) {
205 // If we are in immersive fullscreen and we are anchored to a view in the
206 // top-of-window views (eg omnibox, toolbar), trigger an immersive reveal.
207 // We do not need to hold onto the lock because ImmersiveModeController will
208 // keep the top-of-window views revealed as long as the popup is active.
209 // TODO(pkotwicz): Move logic to ImmersiveModeController.
210 immersive_reveal_lock.reset(
211 browser_view->immersive_mode_controller()->GetRevealedLock(
212 ImmersiveModeController::ANIMATE_REVEAL_NO));
213 SizeToContents();
214 }
196 GetWidget()->Show(); 215 GetWidget()->Show();
197 216
198 // Focus on the host contents when the bubble is first shown. 217 // Focus on the host contents when the bubble is first shown.
199 host()->host_contents()->GetView()->Focus(); 218 host()->host_contents()->GetView()->Focus();
200 219
201 if (inspect_with_devtools_) { 220 if (inspect_with_devtools_) {
202 DevToolsWindow::ToggleDevToolsWindow(host()->render_view_host(), 221 DevToolsWindow::ToggleDevToolsWindow(host()->render_view_host(),
203 true, 222 true,
204 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE); 223 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
205 } 224 }
206 } 225 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_popup.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698