| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()); |
| 108 return tab_struct.Pass(); | 108 return tab_struct.Pass(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 scoped_ptr<windows::Window> CreateWindowModelHelper( | 111 scoped_ptr<windows::Window> CreateWindowModelHelper( |
| 112 scoped_ptr<std::vector<linked_ptr<tabs::Tab> > > tabs, | 112 scoped_ptr<std::vector<linked_ptr<tabs::Tab>>> tabs, |
| 113 const std::string& session_id, | 113 const std::string& session_id, |
| 114 const windows::Window::Type& type, | 114 const windows::Window::Type& type, |
| 115 const windows::Window::State& state) { | 115 const windows::State& state) { |
| 116 scoped_ptr<windows::Window> window_struct(new windows::Window); | 116 scoped_ptr<windows::Window> window_struct(new windows::Window); |
| 117 window_struct->tabs = tabs.Pass(); | 117 window_struct->tabs = tabs.Pass(); |
| 118 window_struct->session_id.reset(new std::string(session_id)); | 118 window_struct->session_id.reset(new std::string(session_id)); |
| 119 window_struct->incognito = false; | 119 window_struct->incognito = false; |
| 120 window_struct->always_on_top = false; | 120 window_struct->always_on_top = false; |
| 121 window_struct->focused = false; | 121 window_struct->focused = false; |
| 122 window_struct->type = type; | 122 window_struct->type = type; |
| 123 window_struct->state = state; | 123 window_struct->state = state; |
| 124 return window_struct.Pass(); | 124 return window_struct.Pass(); |
| 125 } | 125 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 DCHECK(!window.tabs.empty()); | 165 DCHECK(!window.tabs.empty()); |
| 166 | 166 |
| 167 scoped_ptr<std::vector<linked_ptr<tabs::Tab> > > tabs( | 167 scoped_ptr<std::vector<linked_ptr<tabs::Tab> > > tabs( |
| 168 new std::vector<linked_ptr<tabs::Tab> >); | 168 new std::vector<linked_ptr<tabs::Tab> >); |
| 169 for (size_t i = 0; i < window.tabs.size(); ++i) { | 169 for (size_t i = 0; i < window.tabs.size(); ++i) { |
| 170 tabs->push_back(make_linked_ptr( | 170 tabs->push_back(make_linked_ptr( |
| 171 CreateTabModel(window.tabs[i], window.tabs[i].id, | 171 CreateTabModel(window.tabs[i], window.tabs[i].id, |
| 172 window.selected_tab_index).release())); | 172 window.selected_tab_index).release())); |
| 173 } | 173 } |
| 174 | 174 |
| 175 return CreateWindowModelHelper(tabs.Pass(), | 175 return CreateWindowModelHelper(tabs.Pass(), base::IntToString(session_id), |
| 176 base::IntToString(session_id), | |
| 177 windows::Window::TYPE_NORMAL, | 176 windows::Window::TYPE_NORMAL, |
| 178 windows::Window::STATE_NORMAL); | 177 windows::STATE_NORMAL); |
| 179 } | 178 } |
| 180 | 179 |
| 181 scoped_ptr<api::sessions::Session> | 180 scoped_ptr<api::sessions::Session> |
| 182 SessionsGetRecentlyClosedFunction::CreateSessionModel( | 181 SessionsGetRecentlyClosedFunction::CreateSessionModel( |
| 183 const TabRestoreService::Entry* entry) { | 182 const TabRestoreService::Entry* entry) { |
| 184 scoped_ptr<tabs::Tab> tab; | 183 scoped_ptr<tabs::Tab> tab; |
| 185 scoped_ptr<windows::Window> window; | 184 scoped_ptr<windows::Window> window; |
| 186 switch (entry->type) { | 185 switch (entry->type) { |
| 187 case TabRestoreService::TAB: | 186 case TabRestoreService::TAB: |
| 188 tab = CreateTabModel( | 187 tab = CreateTabModel( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 windows::Window::Type type = windows::Window::TYPE_NONE; | 290 windows::Window::Type type = windows::Window::TYPE_NONE; |
| 292 switch (window.type) { | 291 switch (window.type) { |
| 293 case sessions::SessionWindow::TYPE_TABBED: | 292 case sessions::SessionWindow::TYPE_TABBED: |
| 294 type = windows::Window::TYPE_NORMAL; | 293 type = windows::Window::TYPE_NORMAL; |
| 295 break; | 294 break; |
| 296 case sessions::SessionWindow::TYPE_POPUP: | 295 case sessions::SessionWindow::TYPE_POPUP: |
| 297 type = windows::Window::TYPE_POPUP; | 296 type = windows::Window::TYPE_POPUP; |
| 298 break; | 297 break; |
| 299 } | 298 } |
| 300 | 299 |
| 301 windows::Window::State state = windows::Window::STATE_NONE; | 300 windows::State state = windows::STATE_NONE; |
| 302 switch (window.show_state) { | 301 switch (window.show_state) { |
| 303 case ui::SHOW_STATE_NORMAL: | 302 case ui::SHOW_STATE_NORMAL: |
| 304 state = windows::Window::STATE_NORMAL; | 303 state = windows::STATE_NORMAL; |
| 305 break; | 304 break; |
| 306 case ui::SHOW_STATE_MINIMIZED: | 305 case ui::SHOW_STATE_MINIMIZED: |
| 307 state = windows::Window::STATE_MINIMIZED; | 306 state = windows::STATE_MINIMIZED; |
| 308 break; | 307 break; |
| 309 case ui::SHOW_STATE_MAXIMIZED: | 308 case ui::SHOW_STATE_MAXIMIZED: |
| 310 state = windows::Window::STATE_MAXIMIZED; | 309 state = windows::STATE_MAXIMIZED; |
| 311 break; | 310 break; |
| 312 case ui::SHOW_STATE_FULLSCREEN: | 311 case ui::SHOW_STATE_FULLSCREEN: |
| 313 state = windows::Window::STATE_FULLSCREEN; | 312 state = windows::STATE_FULLSCREEN; |
| 314 break; | 313 break; |
| 315 case ui::SHOW_STATE_DEFAULT: | 314 case ui::SHOW_STATE_DEFAULT: |
| 316 case ui::SHOW_STATE_INACTIVE: | 315 case ui::SHOW_STATE_INACTIVE: |
| 317 case ui::SHOW_STATE_END: | 316 case ui::SHOW_STATE_END: |
| 318 break; | 317 break; |
| 319 } | 318 } |
| 320 | 319 |
| 321 scoped_ptr<windows::Window> window_struct( | 320 scoped_ptr<windows::Window> window_struct( |
| 322 CreateWindowModelHelper(tabs.Pass(), session_id, type, state)); | 321 CreateWindowModelHelper(tabs.Pass(), session_id, type, state)); |
| 323 // TODO(dwankri): Dig deeper to resolve bounds not being optional, so closed | 322 // TODO(dwankri): Dig deeper to resolve bounds not being optional, so closed |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 return g_factory.Pointer(); | 648 return g_factory.Pointer(); |
| 650 } | 649 } |
| 651 | 650 |
| 652 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { | 651 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 653 sessions_event_router_.reset( | 652 sessions_event_router_.reset( |
| 654 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); | 653 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); |
| 655 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 654 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 656 } | 655 } |
| 657 | 656 |
| 658 } // namespace extensions | 657 } // namespace extensions |
| OLD | NEW |