OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/api/sessions/sessions_api.h" | 5 #include "chrome/browser/extensions/api/sessions/sessions_api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 25 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
26 #include "chrome/browser/sync/glue/synced_session.h" | 26 #include "chrome/browser/sync/glue/synced_session.h" |
27 #include "chrome/browser/sync/open_tabs_ui_delegate.h" | 27 #include "chrome/browser/sync/open_tabs_ui_delegate.h" |
28 #include "chrome/browser/sync/profile_sync_service.h" | 28 #include "chrome/browser/sync/profile_sync_service.h" |
29 #include "chrome/browser/sync/profile_sync_service_factory.h" | 29 #include "chrome/browser/sync/profile_sync_service_factory.h" |
30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
32 #include "chrome/browser/ui/host_desktop.h" | 32 #include "chrome/browser/ui/host_desktop.h" |
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "components/url_formatter/url_formatter.h" |
35 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
36 #include "extensions/browser/extension_function_dispatcher.h" | 37 #include "extensions/browser/extension_function_dispatcher.h" |
37 #include "extensions/browser/extension_function_registry.h" | 38 #include "extensions/browser/extension_function_registry.h" |
38 #include "extensions/browser/extension_system.h" | 39 #include "extensions/browser/extension_system.h" |
39 #include "extensions/common/error_utils.h" | 40 #include "extensions/common/error_utils.h" |
40 #include "net/base/net_util.h" | |
41 #include "ui/base/layout.h" | 41 #include "ui/base/layout.h" |
42 | 42 |
43 namespace extensions { | 43 namespace extensions { |
44 | 44 |
45 namespace GetRecentlyClosed = api::sessions::GetRecentlyClosed; | 45 namespace GetRecentlyClosed = api::sessions::GetRecentlyClosed; |
46 namespace GetDevices = api::sessions::GetDevices; | 46 namespace GetDevices = api::sessions::GetDevices; |
47 namespace Restore = api::sessions::Restore; | 47 namespace Restore = api::sessions::Restore; |
48 namespace tabs = api::tabs; | 48 namespace tabs = api::tabs; |
49 namespace windows = api::windows; | 49 namespace windows = api::windows; |
50 | 50 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 tab_struct->session_id.reset(new std::string(session_id)); | 87 tab_struct->session_id.reset(new std::string(session_id)); |
88 tab_struct->url.reset(new std::string(url.spec())); | 88 tab_struct->url.reset(new std::string(url.spec())); |
89 tab_struct->fav_icon_url.reset( | 89 tab_struct->fav_icon_url.reset( |
90 new std::string(current_navigation.favicon_url().spec())); | 90 new std::string(current_navigation.favicon_url().spec())); |
91 if (!title.empty()) { | 91 if (!title.empty()) { |
92 tab_struct->title.reset(new std::string(title)); | 92 tab_struct->title.reset(new std::string(title)); |
93 } else { | 93 } else { |
94 const std::string languages = | 94 const std::string languages = |
95 profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 95 profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
96 tab_struct->title.reset( | 96 tab_struct->title.reset(new std::string( |
97 new std::string(base::UTF16ToUTF8(net::FormatUrl(url, languages)))); | 97 base::UTF16ToUTF8(url_formatter::FormatUrl(url, languages)))); |
98 } | 98 } |
99 tab_struct->index = index; | 99 tab_struct->index = index; |
100 tab_struct->pinned = pinned; | 100 tab_struct->pinned = pinned; |
101 // Note: |selected_index| from the sync sessions model is what we call | 101 // Note: |selected_index| from the sync sessions model is what we call |
102 // "active" in extensions terminology. "selected" is deprecated because it's | 102 // "active" in extensions terminology. "selected" is deprecated because it's |
103 // not clear whether it means "active" (user can see) or "highlighted" (user | 103 // not clear whether it means "active" (user can see) or "highlighted" (user |
104 // has highlighted, since you can select tabs without bringing them into the | 104 // has highlighted, since you can select tabs without bringing them into the |
105 // foreground). | 105 // foreground). |
106 tab_struct->active = index == selected_index; | 106 tab_struct->active = index == selected_index; |
107 ExtensionTabUtil::ScrubTabForExtension(extension, tab_struct.get()); | 107 ExtensionTabUtil::ScrubTabForExtension(extension, tab_struct.get()); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 return g_factory.Pointer(); | 649 return g_factory.Pointer(); |
650 } | 650 } |
651 | 651 |
652 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { | 652 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { |
653 sessions_event_router_.reset( | 653 sessions_event_router_.reset( |
654 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); | 654 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); |
655 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 655 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
656 } | 656 } |
657 | 657 |
658 } // namespace extensions | 658 } // namespace extensions |
OLD | NEW |