| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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/file_select_helper.h" | 23 #include "chrome/browser/file_select_helper.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" | 25 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" |
| 26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
| 29 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
| 30 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 30 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
| 31 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 31 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 32 #include "chrome/browser/view_type_utils.h" | 32 #include "chrome/browser/view_type_utils.h" |
| 33 #include "chrome/common/chrome_constants.h" | 33 #include "chrome/common/chrome_constants.h" |
| 34 #include "chrome/common/chrome_notification_types.h" | 34 #include "chrome/common/chrome_notification_types.h" |
| 35 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
| 36 #include "chrome/common/extensions/extension_constants.h" | 36 #include "chrome/common/extensions/extension_constants.h" |
| 37 #include "chrome/common/extensions/extension_messages.h" | 37 #include "chrome/common/extensions/extension_messages.h" |
| 38 #include "chrome/common/render_messages.h" | 38 #include "chrome/common/render_messages.h" |
| 39 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
| 40 #include "content/public/browser/content_browser_client.h" | 40 #include "content/public/browser/content_browser_client.h" |
| 41 #include "content/public/browser/native_web_keyboard_event.h" | 41 #include "content/public/browser/native_web_keyboard_event.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 return; | 585 return; |
| 586 } | 586 } |
| 587 } | 587 } |
| 588 | 588 |
| 589 // Find a browser with a profile that matches the new tab. If none is found, | 589 // Find a browser with a profile that matches the new tab. If none is found, |
| 590 // NULL argument to NavigateParams is valid. | 590 // NULL argument to NavigateParams is valid. |
| 591 Profile* profile = | 591 Profile* profile = |
| 592 Profile::FromBrowserContext(new_contents->GetBrowserContext()); | 592 Profile::FromBrowserContext(new_contents->GetBrowserContext()); |
| 593 Browser* browser = browser::FindTabbedBrowser( | 593 Browser* browser = browser::FindTabbedBrowser( |
| 594 profile, false); // Match incognito exactly. | 594 profile, false); // Match incognito exactly. |
| 595 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); | 595 TabContents* tab_contents = new TabContents(new_contents); |
| 596 browser::NavigateParams params(browser, wrapper); | 596 browser::NavigateParams params(browser, tab_contents); |
| 597 | 597 |
| 598 // The extension_app_id parameter ends up as app_name in the Browser | 598 // The extension_app_id parameter ends up as app_name in the Browser |
| 599 // which causes the Browser to return true for is_app(). This affects | 599 // which causes the Browser to return true for is_app(). This affects |
| 600 // among other things, whether the location bar gets displayed. | 600 // among other things, whether the location bar gets displayed. |
| 601 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted | 601 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted |
| 602 // in a tab? | 602 // in a tab? |
| 603 if (disposition == NEW_POPUP) | 603 if (disposition == NEW_POPUP) |
| 604 params.extension_app_id = extension_id_; | 604 params.extension_app_id = extension_id_; |
| 605 | 605 |
| 606 if (!browser) | 606 if (!browser) |
| 607 params.profile = profile; | 607 params.profile = profile; |
| 608 params.disposition = disposition; | 608 params.disposition = disposition; |
| 609 params.window_bounds = initial_pos; | 609 params.window_bounds = initial_pos; |
| 610 params.window_action = browser::NavigateParams::SHOW_WINDOW; | 610 params.window_action = browser::NavigateParams::SHOW_WINDOW; |
| 611 params.user_gesture = user_gesture; | 611 params.user_gesture = user_gesture; |
| 612 browser::Navigate(¶ms); | 612 browser::Navigate(¶ms); |
| 613 } | 613 } |
| 614 | 614 |
| 615 void ExtensionHost::RenderViewReady() { | 615 void ExtensionHost::RenderViewReady() { |
| 616 content::NotificationService::current()->Notify( | 616 content::NotificationService::current()->Notify( |
| 617 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 617 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 618 content::Source<Profile>(profile_), | 618 content::Source<Profile>(profile_), |
| 619 content::Details<ExtensionHost>(this)); | 619 content::Details<ExtensionHost>(this)); |
| 620 } | 620 } |
| OLD | NEW |