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

Side by Side Diff: chrome/browser/extensions/extension_host.cc

Issue 6881073: Cleanup popup related browser navigation code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and merge with avi's popup block changes. Created 9 years, 8 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/chromeos/frame/browser_view.cc ('k') | chrome/browser/ui/browser.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_host.h" 5 #include "chrome/browser/extensions/extension_host.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "chrome/browser/browser_shutdown.h" 13 #include "chrome/browser/browser_shutdown.h"
14 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/extension_tabs_module.h" 15 #include "chrome/browser/extensions/extension_tabs_module.h"
16 #include "chrome/browser/file_select_helper.h" 16 #include "chrome/browser/file_select_helper.h"
17 #include "chrome/browser/platform_util.h" 17 #include "chrome/browser/platform_util.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/renderer_preferences_util.h" 19 #include "chrome/browser/renderer_preferences_util.h"
20 #include "chrome/browser/tab_contents/popup_menu_helper_mac.h" 20 #include "chrome/browser/tab_contents/popup_menu_helper_mac.h"
21 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" 21 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h"
22 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_list.h" 23 #include "chrome/browser/ui/browser_list.h"
24 #include "chrome/browser/ui/browser_window.h" 24 #include "chrome/browser/ui/browser_window.h"
25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
25 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" 26 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
26 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/extensions/extension.h" 28 #include "chrome/common/extensions/extension.h"
28 #include "chrome/common/extensions/extension_constants.h" 29 #include "chrome/common/extensions/extension_constants.h"
29 #include "chrome/common/render_messages.h" 30 #include "chrome/common/render_messages.h"
30 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
31 #include "chrome/common/view_types.h" 32 #include "chrome/common/view_types.h"
32 #include "content/browser/browsing_instance.h" 33 #include "content/browser/browsing_instance.h"
33 #include "content/browser/renderer_host/browser_render_process_host.h" 34 #include "content/browser/renderer_host/browser_render_process_host.h"
34 #include "content/browser/renderer_host/render_process_host.h" 35 #include "content/browser/renderer_host/render_process_host.h"
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 589
589 void ExtensionHost::ShowCreatedWindow(int route_id, 590 void ExtensionHost::ShowCreatedWindow(int route_id,
590 WindowOpenDisposition disposition, 591 WindowOpenDisposition disposition,
591 const gfx::Rect& initial_pos, 592 const gfx::Rect& initial_pos,
592 bool user_gesture) { 593 bool user_gesture) {
593 TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id); 594 TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id);
594 if (!contents) 595 if (!contents)
595 return; 596 return;
596 597
597 if (disposition == NEW_POPUP) { 598 if (disposition == NEW_POPUP) {
598 // Create a new Browser window of type TYPE_APP_POPUP. 599 // Find a browser with a matching profile for creating a popup.
599 // (AddTabContents would otherwise create a window of type TYPE_POPUP). 600 // (If none is found, NULL argument to NavigateParams is valid).
Avi (use Gerrit) 2011/04/28 19:27:10 Period inside parens.
600 Browser* browser = Browser::CreateForPopup(Browser::TYPE_APP_POPUP, 601 Browser* browser = BrowserList::FindBrowserWithType(
601 contents->profile(), 602 contents->profile(),
602 contents, 603 Browser::TYPE_NORMAL,
603 initial_pos); 604 false); // Match incognito exactly.
604 if (user_gesture) 605 TabContentsWrapper* wrapper = new TabContentsWrapper(contents);
605 browser->window()->Show(); 606 browser::NavigateParams params(browser, wrapper);
606 else 607 params.disposition = NEW_POPUP;
607 browser->window()->ShowInactive(); 608 params.window_bounds = initial_pos;
609 params.window_action = browser::NavigateParams::SHOW_WINDOW;
610 params.user_gesture = user_gesture;
611 browser::Navigate(&params);
608 return; 612 return;
609 } 613 }
610 614
611 // If the tab contents isn't a popup, it's a normal tab. We need to find a 615 // If the tab contents isn't a popup, it's a normal tab. We need to find a
612 // home for it. This is typically a Browser, but it can also be some other 616 // home for it. This is typically a Browser, but it can also be some other
613 // TabContentsDelegate in the case of ChromeFrame. 617 // TabContentsDelegate in the case of ChromeFrame.
614 618
615 // First, if the creating extension view was associated with a tab contents, 619 // First, if the creating extension view was associated with a tab contents,
616 // use that tab content's delegate. We must be careful here that the 620 // use that tab content's delegate. We must be careful here that the
617 // associated tab contents has the same profile as the new tab contents. In 621 // associated tab contents has the same profile as the new tab contents. In
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 return window_id; 834 return window_id;
831 } 835 }
832 836
833 void ExtensionHost::OnRunFileChooser( 837 void ExtensionHost::OnRunFileChooser(
834 const ViewHostMsg_RunFileChooser_Params& params) { 838 const ViewHostMsg_RunFileChooser_Params& params) {
835 if (file_select_helper_.get() == NULL) 839 if (file_select_helper_.get() == NULL)
836 file_select_helper_.reset(new FileSelectHelper(profile())); 840 file_select_helper_.reset(new FileSelectHelper(profile()));
837 file_select_helper_->RunFileChooser(render_view_host_, 841 file_select_helper_->RunFileChooser(render_view_host_,
838 associated_tab_contents(), params); 842 associated_tab_contents(), params);
839 } 843 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/frame/browser_view.cc ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698