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

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: Fix Popup tests for ChromeOS. 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
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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 597
597 void ExtensionHost::ShowCreatedWindow(int route_id, 598 void ExtensionHost::ShowCreatedWindow(int route_id,
598 WindowOpenDisposition disposition, 599 WindowOpenDisposition disposition,
599 const gfx::Rect& initial_pos, 600 const gfx::Rect& initial_pos,
600 bool user_gesture) { 601 bool user_gesture) {
601 TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id); 602 TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id);
602 if (!contents) 603 if (!contents)
603 return; 604 return;
604 605
605 if (disposition == NEW_POPUP) { 606 if (disposition == NEW_POPUP) {
606 // Create a new Browser window of type TYPE_APP_POPUP. 607 // Find a browser with a matching profile for creating a popup.
607 // (AddTabContents would otherwise create a window of type TYPE_POPUP). 608 // (If none is found, NULL argument to NavigateParams is valid).
608 Browser* browser = Browser::CreateForPopup(Browser::TYPE_APP_POPUP, 609 Browser* browser = BrowserList::FindBrowserWithType(
609 contents->profile(), 610 contents->profile(),
610 contents, 611 Browser::TYPE_NORMAL,
611 initial_pos); 612 false); // Match incognito exactly.
612 if (user_gesture) 613 TabContentsWrapper* wrapper = new TabContentsWrapper(contents);
613 browser->window()->Show(); 614 browser::NavigateParams params(browser, wrapper);
614 else 615 params.disposition = NEW_POPUP;
615 browser->window()->ShowInactive(); 616 params.window_bounds = initial_pos;
617 params.window_action = browser::NavigateParams::SHOW_WINDOW;
618 params.user_gesture = user_gesture;
619 browser::Navigate(&params);
616 return; 620 return;
617 } 621 }
618 622
619 // If the tab contents isn't a popup, it's a normal tab. We need to find a 623 // If the tab contents isn't a popup, it's a normal tab. We need to find a
620 // home for it. This is typically a Browser, but it can also be some other 624 // home for it. This is typically a Browser, but it can also be some other
621 // TabContentsDelegate in the case of ChromeFrame. 625 // TabContentsDelegate in the case of ChromeFrame.
622 626
623 // First, if the creating extension view was associated with a tab contents, 627 // First, if the creating extension view was associated with a tab contents,
624 // use that tab content's delegate. We must be careful here that the 628 // use that tab content's delegate. We must be careful here that the
625 // associated tab contents has the same profile as the new tab contents. In 629 // associated tab contents has the same profile as the new tab contents. In
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 return window_id; 837 return window_id;
834 } 838 }
835 839
836 void ExtensionHost::OnRunFileChooser( 840 void ExtensionHost::OnRunFileChooser(
837 const ViewHostMsg_RunFileChooser_Params& params) { 841 const ViewHostMsg_RunFileChooser_Params& params) {
838 if (file_select_helper_.get() == NULL) 842 if (file_select_helper_.get() == NULL)
839 file_select_helper_.reset(new FileSelectHelper(profile())); 843 file_select_helper_.reset(new FileSelectHelper(profile()));
840 file_select_helper_->RunFileChooser(render_view_host_, 844 file_select_helper_->RunFileChooser(render_view_host_,
841 associated_tab_contents(), params); 845 associated_tab_contents(), params);
842 } 846 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698