OLD | NEW |
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/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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
17 #include "chrome/browser/extensions/extension_event_router.h" | 17 #include "chrome/browser/extensions/extension_event_router.h" |
18 #include "chrome/browser/extensions/extension_process_manager.h" | 18 #include "chrome/browser/extensions/extension_process_manager.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/extension_system.h" | 20 #include "chrome/browser/extensions/extension_system.h" |
21 #include "chrome/browser/extensions/extension_tab_util.h" | 21 #include "chrome/browser/extensions/extension_tab_util.h" |
22 #include "chrome/browser/extensions/extension_window_controller.h" | 22 #include "chrome/browser/extensions/extension_window_controller.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" | 24 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" |
25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_finder.h" |
26 #include "chrome/browser/ui/browser_list.h" | 27 #include "chrome/browser/ui/browser_list.h" |
27 #include "chrome/browser/ui/browser_window.h" | 28 #include "chrome/browser/ui/browser_window.h" |
28 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 29 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 30 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
30 #include "chrome/common/chrome_constants.h" | 31 #include "chrome/common/chrome_constants.h" |
31 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
32 #include "chrome/common/chrome_view_type.h" | 33 #include "chrome/common/chrome_view_type.h" |
33 #include "chrome/common/extensions/extension.h" | 34 #include "chrome/common/extensions/extension.h" |
34 #include "chrome/common/extensions/extension_constants.h" | 35 #include "chrome/common/extensions/extension_constants.h" |
35 #include "chrome/common/extensions/extension_messages.h" | 36 #include "chrome/common/extensions/extension_messages.h" |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 associated_contents->AddNewContents( | 558 associated_contents->AddNewContents( |
558 new_contents, disposition, initial_pos, user_gesture); | 559 new_contents, disposition, initial_pos, user_gesture); |
559 return; | 560 return; |
560 } | 561 } |
561 } | 562 } |
562 | 563 |
563 // Find a browser with a profile that matches the new tab. If none is found, | 564 // Find a browser with a profile that matches the new tab. If none is found, |
564 // NULL argument to NavigateParams is valid. | 565 // NULL argument to NavigateParams is valid. |
565 Profile* profile = | 566 Profile* profile = |
566 Profile::FromBrowserContext(new_contents->GetBrowserContext()); | 567 Profile::FromBrowserContext(new_contents->GetBrowserContext()); |
567 Browser* browser = BrowserList::FindTabbedBrowser( | 568 Browser* browser = browser::FindTabbedBrowser( |
568 profile, false); // Match incognito exactly. | 569 profile, false); // Match incognito exactly. |
569 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); | 570 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); |
570 browser::NavigateParams params(browser, wrapper); | 571 browser::NavigateParams params(browser, wrapper); |
571 | 572 |
572 // The extension_app_id parameter ends up as app_name in the Browser | 573 // The extension_app_id parameter ends up as app_name in the Browser |
573 // which causes the Browser to return true for is_app(). This affects | 574 // which causes the Browser to return true for is_app(). This affects |
574 // among other things, whether the location bar gets displayed. | 575 // among other things, whether the location bar gets displayed. |
575 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted | 576 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted |
576 // in a tab? | 577 // in a tab? |
577 if (disposition == NEW_POPUP) | 578 if (disposition == NEW_POPUP) |
578 params.extension_app_id = extension_id_; | 579 params.extension_app_id = extension_id_; |
579 | 580 |
580 if (!browser) | 581 if (!browser) |
581 params.profile = profile; | 582 params.profile = profile; |
582 params.disposition = disposition; | 583 params.disposition = disposition; |
583 params.window_bounds = initial_pos; | 584 params.window_bounds = initial_pos; |
584 params.window_action = browser::NavigateParams::SHOW_WINDOW; | 585 params.window_action = browser::NavigateParams::SHOW_WINDOW; |
585 params.user_gesture = user_gesture; | 586 params.user_gesture = user_gesture; |
586 browser::Navigate(¶ms); | 587 browser::Navigate(¶ms); |
587 } | 588 } |
588 | 589 |
589 void ExtensionHost::RenderViewReady() { | 590 void ExtensionHost::RenderViewReady() { |
590 content::NotificationService::current()->Notify( | 591 content::NotificationService::current()->Notify( |
591 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 592 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
592 content::Source<Profile>(profile_), | 593 content::Source<Profile>(profile_), |
593 content::Details<ExtensionHost>(this)); | 594 content::Details<ExtensionHost>(this)); |
594 } | 595 } |
OLD | NEW |