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

Side by Side Diff: chrome/browser/extensions/api/tabs/app_window_controller.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/tabs/app_window_controller.h" 5 #include "chrome/browser/extensions/api/tabs/app_window_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/extensions/api/tabs/app_base_window.h" 11 #include "chrome/browser/extensions/api/tabs/app_base_window.h"
12 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 12 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
13 #include "chrome/browser/extensions/extension_tab_util.h" 13 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/extensions/window_controller.h" 14 #include "chrome/browser/extensions/window_controller.h"
15 #include "chrome/browser/extensions/window_controller_list.h" 15 #include "chrome/browser/extensions/window_controller_list.h"
16 #include "chrome/browser/sessions/session_tab_helper.h" 16 #include "chrome/browser/sessions/session_tab_helper.h"
17 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
18 #include "extensions/browser/app_window/app_window.h" 18 #include "extensions/browser/app_window/app_window.h"
19 #include "extensions/browser/app_window/native_app_window.h" 19 #include "extensions/browser/app_window/native_app_window.h"
20 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
21 21
22 namespace extensions { 22 namespace extensions {
23 23
24 AppWindowController::AppWindowController(AppWindow* app_window, 24 AppWindowController::AppWindowController(
25 scoped_ptr<AppBaseWindow> base_window, 25 AppWindow* app_window,
26 Profile* profile) 26 std::unique_ptr<AppBaseWindow> base_window,
27 Profile* profile)
27 : WindowController(base_window.get(), profile), 28 : WindowController(base_window.get(), profile),
28 app_window_(app_window), 29 app_window_(app_window),
29 base_window_(std::move(base_window)) { 30 base_window_(std::move(base_window)) {
30 WindowControllerList::GetInstance()->AddExtensionWindow(this); 31 WindowControllerList::GetInstance()->AddExtensionWindow(this);
31 } 32 }
32 33
33 AppWindowController::~AppWindowController() { 34 AppWindowController::~AppWindowController() {
34 WindowControllerList::GetInstance()->RemoveExtensionWindow(this); 35 WindowControllerList::GetInstance()->RemoveExtensionWindow(this);
35 } 36 }
36 37
(...skipping 21 matching lines...) Expand all
58 59
59 return result; 60 return result;
60 } 61 }
61 62
62 base::DictionaryValue* AppWindowController::CreateTabValue( 63 base::DictionaryValue* AppWindowController::CreateTabValue(
63 const Extension* extension, 64 const Extension* extension,
64 int tab_index) const { 65 int tab_index) const {
65 return CreateTabObject(extension, tab_index)->ToValue().release(); 66 return CreateTabObject(extension, tab_index)->ToValue().release();
66 } 67 }
67 68
68 scoped_ptr<api::tabs::Tab> AppWindowController::CreateTabObject( 69 std::unique_ptr<api::tabs::Tab> AppWindowController::CreateTabObject(
69 const extensions::Extension* extension, 70 const extensions::Extension* extension,
70 int tab_index) const { 71 int tab_index) const {
71 if (tab_index > 0) 72 if (tab_index > 0)
72 return nullptr; 73 return nullptr;
73 74
74 content::WebContents* web_contents = app_window_->web_contents(); 75 content::WebContents* web_contents = app_window_->web_contents();
75 if (!web_contents) 76 if (!web_contents)
76 return nullptr; 77 return nullptr;
77 78
78 scoped_ptr<api::tabs::Tab> tab_object(new api::tabs::Tab); 79 std::unique_ptr<api::tabs::Tab> tab_object(new api::tabs::Tab);
79 tab_object->id.reset(new int(SessionTabHelper::IdForTab(web_contents))); 80 tab_object->id.reset(new int(SessionTabHelper::IdForTab(web_contents)));
80 tab_object->index = 0; 81 tab_object->index = 0;
81 tab_object->window_id = 82 tab_object->window_id =
82 SessionTabHelper::IdForWindowContainingTab(web_contents); 83 SessionTabHelper::IdForWindowContainingTab(web_contents);
83 tab_object->url.reset(new std::string(web_contents->GetURL().spec())); 84 tab_object->url.reset(new std::string(web_contents->GetURL().spec()));
84 tab_object->status.reset(new std::string( 85 tab_object->status.reset(new std::string(
85 ExtensionTabUtil::GetTabStatusText(web_contents->IsLoading()))); 86 ExtensionTabUtil::GetTabStatusText(web_contents->IsLoading())));
86 tab_object->active = app_window_->GetBaseWindow()->IsActive(); 87 tab_object->active = app_window_->GetBaseWindow()->IsActive();
87 tab_object->selected = true; 88 tab_object->selected = true;
88 tab_object->highlighted = true; 89 tab_object->highlighted = true;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 return nullptr; 124 return nullptr;
124 } 125 }
125 126
126 bool AppWindowController::IsVisibleToExtension( 127 bool AppWindowController::IsVisibleToExtension(
127 const Extension* extension) const { 128 const Extension* extension) const {
128 DCHECK(extension); 129 DCHECK(extension);
129 return extension->id() == app_window_->extension_id(); 130 return extension->id() == app_window_->extension_id();
130 } 131 }
131 132
132 } // namespace extensions 133 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/app_window_controller.h ('k') | chrome/browser/extensions/api/tabs/ash_panel_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698