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

Side by Side Diff: chrome/browser/ui/android/tab_model/android_live_tab_context.h

Issue 2088443003: Shortcut ctrl+shift+T added on android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wire android tab model with LiveTabContext, so when access tab restore service, we don't hurt its c… Created 4 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
sky 2016/06/28 19:13:37 nit: no (c) (see style guide).
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 #ifndef CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ 5 #ifndef CHROME_BROWSER_UI_ANDROID_TAB_MODEL_ANDROID_LIVE_TAB_CONTEXT_H_
6 #define CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ 6 #define CHROME_BROWSER_UI_ANDROID_TAB_MODEL_ANDROID_LIVE_TAB_CONTEXT_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/sessions/core/live_tab_context.h" 13 #include "components/sessions/core/live_tab_context.h"
14 14
15 class Browser;
16 class Profile;
17
18 namespace content { 15 namespace content {
19 class WebContents; 16 class WebContents;
20 } 17 }
21 18
22 // Implementation of LiveTabContext which uses an instance of 19 class TabModel;
23 // Browser in order to fulfil its duties. 20
24 class BrowserLiveTabContext : public sessions::LiveTabContext { 21 // Implementation of LiveTabContext which used by android.
22 // Serve as adapter to LiveTabContext.
23 class AndroidLiveTabContext : public sessions::LiveTabContext {
25 public: 24 public:
26 explicit BrowserLiveTabContext(Browser* browser) : browser_(browser) {} 25 explicit AndroidLiveTabContext(TabModel* tab_model)
27 ~BrowserLiveTabContext() override {} 26 : tab_model_(tab_model) {
sky 2016/06/28 19:13:37 Don't inline constructor/destructor (see style gui
27 }
28 ~AndroidLiveTabContext() override {}
28 29
29 // Overridden from LiveTabContext: 30 // Overridden from LiveTabContext:
30 void ShowBrowserWindow() override; 31 void ShowBrowserWindow() override;
31 const SessionID& GetSessionID() const override; 32 const SessionID& GetSessionID() const override;
32 int GetTabCount() const override; 33 int GetTabCount() const override;
33 int GetSelectedIndex() const override; 34 int GetSelectedIndex() const override;
34 std::string GetAppName() const override; 35 std::string GetAppName() const override;
35 sessions::LiveTab* GetLiveTabAt(int index) const override; 36 sessions::LiveTab* GetLiveTabAt(int index) const override;
36 sessions::LiveTab* GetActiveLiveTab() const override; 37 sessions::LiveTab* GetActiveLiveTab() const override;
37 bool IsTabPinned(int index) const override; 38 bool IsTabPinned(int index) const override;
38 sessions::LiveTab* AddRestoredTab( 39 sessions::LiveTab* AddRestoredTab(
39 const std::vector<sessions::SerializedNavigationEntry>& navigations, 40 const std::vector<sessions::SerializedNavigationEntry>& navigations,
40 int tab_index, 41 int tab_index,
41 int selected_navigation, 42 int selected_navigation,
42 const std::string& extension_app_id, 43 const std::string& extension_app_id,
43 bool select, 44 bool select,
44 bool pin, 45 bool pin,
45 bool from_last_session, 46 bool from_last_session,
46 const sessions::PlatformSpecificTabData* storage_namespace, 47 const sessions::PlatformSpecificTabData* storage_namespace,
47 const std::string& user_agent_override) override; 48 const std::string& user_agent_override) override;
48 sessions::LiveTab* ReplaceRestoredTab( 49 sessions::LiveTab* ReplaceRestoredTab(
49 const std::vector<sessions::SerializedNavigationEntry>& navigations, 50 const std::vector<sessions::SerializedNavigationEntry>& navigations,
50 int selected_navigation, 51 int selected_navigation,
51 bool from_last_session, 52 bool from_last_session,
52 const std::string& extension_app_id, 53 const std::string& extension_app_id,
53 const sessions::PlatformSpecificTabData* tab_platform_data, 54 const sessions::PlatformSpecificTabData* tab_platform_data,
54 const std::string& user_agent_override) override; 55 const std::string& user_agent_override) override;
55 void CloseTab() override; 56 void CloseTab() override;
56 57
57 // see Browser::Create 58 static LiveTabContext* FindContextForWebContents(const
58 static sessions::LiveTabContext* Create( 59 content::WebContents* contents);
59 Profile* profile,
60 const std::string& app_name);
61
62 // see browser::FindBrowserForWebContents
63 static sessions::LiveTabContext* FindContextForWebContents(
64 const content::WebContents* contents);
65
66 // see chrome::FindBrowserWithID
67 // Returns the LiveTabContext of the Browser with |desired_id| if
68 // such a Browser exists.
69 static sessions::LiveTabContext* FindContextWithID(
70 SessionID::id_type desired_id);
71
72 private: 60 private:
73 Browser* browser_; 61 TabModel* tab_model_;
74 62 DISALLOW_COPY_AND_ASSIGN(AndroidLiveTabContext);
75 DISALLOW_COPY_AND_ASSIGN(BrowserLiveTabContext);
76 }; 63 };
77 64
78 #endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ 65
66 #endif // CHROME_BROWSER_UI_ANDROID_TAB_MODEL_ANDROID_LIVE_TAB_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698